-
Notifications
You must be signed in to change notification settings - Fork 378
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
in variable initialization, dependencies within functions are not recursively resolved #1463
Comments
This PR fixes [this](#1849) and [this](#1463). Before preprocessing, a dependency graph is created and edges between the nodes which represent the relationship between global `var` and `const` declarations. Then, a new slice of declarations is created that is topologically sorted. This enables the rest of the preprocessing code to work the way it is now. Small scale refactoring is included by removing unnecessary else statements in `PredefineFileSet`.
This bug exists because gnovm's "compilation" unit is a file and the Go compiler's compilation unit is a package. After a conversation @jaekwon , we will wait for his evaluation of the problem and reach a conclusion if the graph would be used or not. |
This is not true, |
this is not what i meant. |
|
By "unit of processing is a file", what I understand is that the implementation of the language is considering the individual file rather than the package, especially when resolving dependencies for names. The obvious example of a language that does this is C, which requires you to import header files for anything else you want to import. Go, and Gno by extension, are not like this and will support referencing names within the same package. This is a feature of both languages that exists and is implemented; albeit the Gno implementation is undoubtedly still with many more bugs. Of course, there is one notable exception and that is that package imports are scoped within the file they are declared. For this reason, it is still important for the implementation both in Go and in Gno to keep track of individual files, as they have different imports and as such can have different sets of "global" identifiers. The fact that the GnoVM processes the package by iterating over each file is not behaviour specific to the GnoVM, inconsistent with what there is in Go. The Go implementation still very much works on individual files deep into the compiling process. Here's an example in the type checker, here's an example in the "noder" (converter to IR) So, no, as far as I'm concerned, the problem is not architectural as you claim, ie. us having a "file" compilation unit while Go having a "package" compilation unit. |
This is unralated in 2 different ways, at least. |
this is where all package level variables are collected.
|
This works:
But this doesn't:
EDIT: After #1854, this is still an issue, you just need to spleet it in different files.
The text was updated successfully, but these errors were encountered: