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 fields should be visible even if marked as @(private="file") #457

Open
greenya opened this issue Jul 31, 2024 · 0 comments
Open

Struct fields should be visible even if marked as @(private="file") #457

greenya opened this issue Jul 31, 2024 · 0 comments

Comments

@greenya
Copy link

greenya commented Jul 31, 2024

When i use multiple files, one file defines something that is marked as @(private="file") and it uses it freely and intellisense works fine. But this type is totally not visible from other file by the intellisense even if its a valid Odin code, e.g. the first file defines some public identifier that has a "hidden" type, so when we get an instance from any file we should be able to see the fields of that type. Basically the intention is to hide the type itself to do not pollute global scope because there is no need to create instances of that type outside the file, but existing instances (which are created by that file) should be visible to instellisense, as Odin allows it without issues.

The following example demonstrates it:

// data.odin --------------------
@(private="file")
Entry :: struct {
    name: string,
    value: int,
}
data_entries := [] Entry {
    { name="entry 41", value=51 },
    { name="entry 42", value=52 },
    { name="entry 43", value=53 },
}
// main.odin ---------------------
get_entry_name :: proc (idx: int) -> string {
    return data_entries[idx].name /* no help with fields when we type "." */
}
main :: proc () {
    fmt.println(get_entry_name(1)) // prints "entry 42"
}

Intellisense will not help there until we remove @(private="file") from Entry definition. Please note, the code compiles and works as expected.

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