struct MyStruct {
var privateInt = 3;
function secretFunction() {
printf("~secrets~\n");
}
}
function main() {
var myStruct: MyStruct = struct MyStruct;
myStruct.secretFunction();
printf("%d\n", myStruct.privateInt);
}
[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
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
publickeyword. I would expect that those without thepublickeyword 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