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

Cannot instantiate struct inside self, if within module (from include) #1

Open
Caleb-o opened this issue Aug 3, 2023 · 0 comments
Open

Comments

@Caleb-o
Copy link
Owner

Caleb-o commented Aug 3, 2023

The only way that this is possible, is if we use this(...), as every method is attached with an instance of some degree. If we use the type name, is will try to find it in the global scope, to which, it cannot. Currently, items will only be put into the global scope, if it's the main file in global scope, or an include is processed with no module alias. The compiler might need to get extra information, then infer that the type name should reference this instead, which will allow it to work as intended with the illusion of using the type name.

One issue with this approach, is that if we're referring to another type in the module, it will run into the same issue and won't work. Next solution would be to infer property accesses to get the type needed, but this will become difficult as it requires knowledge of all modules/structs it is nested within too.

// File a
struct Foo {
    static fn new { Foo() };
}
// File b
include 'a' in a;

let a = a.Foo.new();
@Caleb-o Caleb-o changed the title Cannot instantiate struct inside self, if within module Cannot instantiate struct inside self, if within module (from include) Aug 3, 2023
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