Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct members are always public #119

Open
TheSpydog opened this issue Mar 23, 2019 · 0 comments
Open

Struct members are always public #119

TheSpydog opened this issue Mar 23, 2019 · 0 comments

Comments

@TheSpydog
Copy link
Contributor

Describe the problem. What did you see? What did you expect to see?

All fields and functions of structs are public, even those without the public keyword. I would expect that those without the public keyword are private and inaccessible from outside the struct itself.

If this is a code issue, provide a minimal code example:

struct MyStruct {
        var privateInt = 3;
        function secretFunction() {
                printf("~secrets~\n");
        }
}

function main() {
        var myStruct: MyStruct = struct MyStruct;
        myStruct.secretFunction();
        printf("%d\n", myStruct.privateInt);
}

Environment

[2019-03-22 23:51:17.7379] ===> kitc version
[2019-03-22 23:51:17.7389] DBG: 0.1.0
[2019-03-22 23:51:17.7393] ===> OS
[2019-03-22 23:51:17.7397] DBG: darwin
[2019-03-22 23:51:17.7401] ===> Compiler
[2019-03-22 23:51:17.7405] DBG: /usr/bin/gcc
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
[2019-03-22 23:51:17.7672] ===> Include paths
[2019-03-22 23:51:17.7676] DBG: ["/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks (framework directory)","/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include","/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include","/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include","/usr/local/include"]
[2019-03-22 23:51:17.7739] ===> Compiler flags
[2019-03-22 23:51:17.7743] DBG: ["-D_GNU_SOURCE","-D_BSD_SOURCE","-D_DEFAULT_SOURCE","-std=c99","-pedantic","-O3","-Os","-U__BLOCKS__","-Wno-expansion-to-defined","-Wno-gnu-zero-variadic-macro-arguments","-Wno-missing-braces","-Wno-shift-op-parentheses"]
[2019-03-22 23:51:17.7755] ===> Linker flags
[2019-03-22 23:51:17.7759] DBG: []
[2019-03-22 23:51:17.7763] ===> Source paths
[2019-03-22 23:51:17.7767] DBG: [".","/usr/local/lib/kit"]
[2019-03-22 23:51:17.7771] ===> Standard prelude location
[2019-03-22 23:51:17.7776] DBG: /usr/local/lib/kit/prelude.kit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant