Skip to content

Fix extern reference matching - #245

Merged
JonatanWaern merged 4 commits into
mainfrom
fix-extern-matching
Oct 28, 2026
Merged

JonatanWaern merged 4 commits into
mainfrom
fix-extern-matching

Conversation

@JonatanWaern

Copy link
Copy Markdown
Contributor

Fixes issue #236

  • Regression test extern lookups
  • Fix reference matching vs extern symbols

@JonatanWaern
JonatanWaern requested review from TSonono and a balanced review from Copilot October 26, 2026 09:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

Updates extern declaration handling so extern symbols participate correctly in reference matching and goto-definition, with a new regression test covering extern lookups.

Changes:

  • Add extern declarations as first-class structure objects and include them in symbol collection / collision reporting.
  • Wire externs into templating + analysis symbol tables and lookup paths.
  • Add a regression test for goto-ref/goto-def around extern function/value declarations.
File Description
tests/​test_files/​basic_lookup.dml Adds a regression case for extern declarations and references.
src/​analysis/​templating/​objects.rs Collects extern declarations into object specs and exposes them as shallow components/symbols.
src/​analysis/​structure/​toplevel.rs Routes parsed externs through StatementSpec instead of a dedicated TopLevel.externs field.
src/​analysis/​structure/​objects.rs Introduces Extern as a distinct structure type and updates object conversion.
src/​analysis/​parsing/​structure.rs Adds ExternContent parse node and simplifies extern parsing.
src/​analysis/​mod.rs Enables symbol creation/lookup for extern shallow objects.
CHANGELOG.md Documents the extern reference-matching fix.

Review effort: Lite

Comment thread src/analysis/templating/objects.rs Resolved
Comment thread src/analysis/structure/objects.rs Resolved
Comment thread src/analysis/structure/objects.rs Resolved
Comment thread src/analysis/templating/objects.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/analysis/templating/objects.rs Outdated
Comment on lines +1851 to +1853
// Externs are unconditional and unranked by definition
for extrn in &spec.spec.externs {
externs.push(extrn.clone());
@JonatanWaern
JonatanWaern requested a balanced review from Copilot October 27, 2026 13:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues

Review effort: Lite

Comment thread src/analysis/parsing/structure.rs Resolved
Comment thread src/analysis/templating/objects.rs Resolved
Comment thread src/analysis/templating/objects.rs Resolved
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
In current DML, this cannot happen, in future DML when we have conditional imports
this _could_ happen if we conditionally import a file with an extern decl

Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>

@TSonono TSonono left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried it, and it seemingly works, thanks for the fix

@JonatanWaern
JonatanWaern merged commit 3caaf4e into main Oct 28, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

3 participants