Fix several issues related to name resolving

Closes #358 (closed) Closes #191 (closed) Closes #139 (closed) Closes #300 (closed) Closes #274 (closed) Closes #155 (closed)

Helpful context for reviewing

  • std::conv existed, but std didn't, which made lookup hard and errorprone, so I added a dummy module for that.
  • Looking at the SymbolTable, I saw that written modules showed up as mod <their_name> whereas stdlib file modules were all mod std, found out that they used the first instead of their last path segment as a name and fixed that.
  • Made lookup_type_symbol, lookup_variable and macro_generated lookup functions use lookup_final_id instead of their own half-baked alias resolving thing
  • lookup_final_id now also keeps track of already used aliases and forbids them for the next lookup
  • try_lookup_id now calls lookup_id instead of the other way around, to give errors more detailed context (same for lookup_final_id)
  • lookup_id_with_forbidden is now just lookup_id
  • lookup_id now searches for the first thing in the path if it can't find something directly, resolves that to an absolute path if it's an alias and prepends that on the given path.

Open stuff

lookup_id_in_namespace currently only changes the namespace, but not the base_namespace, which means that using an alias starting with lib:: from another library would in theory use the wrong library.

This is probably fine tho because in add_alias we already expand the lib:: to the base namespace.

#358 (comment 2326833144) Better error message for this

Author checklist

  • New Diagnostics have at least one snapshot test that triggers it
  • Added a changelog entry, if relevant
    • You can use ./add_changelog <MR number or a_descriptive_name> to do this
Edited by DasLixou

Merge request reports

Loading
Loading