Wrong TyStructDecl::call_path
when using glob imports with local shadowing
#5500
Labels
bug
Something isn't working
compiler: frontend
Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
compiler
General compiler. Should eventually become more specific as the issue is triaged
#5418 fixed the issue of finding the proper decls in the namespace in case of shadowing, but it turns out we still have issues in the content of the found decls. The concrete example is having
TyStructDecl::call_path
containing wrong path, namely not the one to the local struct but the one to the shadowed struct, although the rest of the decl contains valid information.To observe the wrong
call_path
, we need to debug the compiler. As a sample tryout project, create a new Sway script with an internal library lib.sw containing the following code:Put the following code in main.sw:
The program will compile without errors, thus resolving the local
TestStruct
as fixed in #5418.To observe the erroneous behavior, go to sway-core/src/type_system/info.rs, to
TypeInfo::apply_subfields
and add the following debugging lines into the secondmatch
armSome(field) =>
:The output will be as follows:
Note that the fields are valid, and that also the span points to the local
TestStruct
.Comment out the
TestStruct
in the lib.sw and rebuild the project. This time, as expected, thecall_path
will contain the valid path to the localTestStruct
in main.sw.Fixing this issue will also need to check:
The text was updated successfully, but these errors were encountered: