Skip to content

Fix text format outer aliases from recent refactor - #2631

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
alexcrichton:fix-text-format-bug
Aug 31, 2026
Merged

Fix text format outer aliases from recent refactor#2631
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
alexcrichton:fix-text-format-bug

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

This commit fixes a regression from #2621 where the resolution of $foo names in the text format of components was refactored. Specifically after that refactoring this component no longer produced a valid binary:

(component $A
  (type $a string)

  (component $B
    (type (instance (export "a" (type (eq $a)))))
    (type $b (record (field "x" $a)))
  )
)

The reason for this is that $a is used twice as implicitly-injected outer aliases here, but the higher-depth one comes first. The previous behavior would leave the $a name on the injected outer alias type, which then caused the resolution of (eq $a) to resolve to the $a within the definition of $B (despite it being later and invalid to reference), instead of the definition within $A which was the target.

The fix here is to leave off the name in the injected outer alias. This preserves the behavior pre-#2621 which was accidentally removed, and causes the above component to generate a valid binary instead of an invalid binary.

This has various bits and pieces of impact throughout tests which now resolve slightly differently than before, or are missing a $foo name, as expected.

This commit fixes a regression from bytecodealliance#2621 where the resolution of `$foo`
names in the text format of components was refactored. Specifically
after that refactoring this component no longer produced a valid binary:

    (component $A
      (type $a string)

      (component $B
        (type (instance (export "a" (type (eq $a)))))
        (type $b (record (field "x" $a)))
      )
    )

The reason for this is that `$a` is used twice as implicitly-injected
outer aliases here, but the higher-depth one comes first. The previous
behavior would leave the `$a` name on the injected outer alias type,
which then caused the resolution of `(eq $a)` to resolve to the `$a`
within the definition of `$B` (despite it being later and invalid to
reference), instead of the definition within `$A` which was the target.

The fix here is to leave off the name in the injected outer alias. This
preserves the behavior pre-bytecodealliance#2621 which was accidentally removed, and
causes the above component to generate a valid binary instead of an
invalid binary.

This has various bits and pieces of impact throughout tests which now
resolve slightly differently than before, or are missing a `$foo` name,
as expected.
@alexcrichton
alexcrichton requested a review from a team as a code owner August 31, 2026 17:04
@alexcrichton
alexcrichton requested review from pchickey and removed request for a team August 31, 2026 17:04
@alexcrichton
alexcrichton added this pull request to the merge queue Aug 31, 2026
Merged via the queue into bytecodealliance:main with commit 2affea5 Aug 31, 2026
37 checks passed
@alexcrichton
alexcrichton deleted the fix-text-format-bug branch August 31, 2026 17:35
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.

2 participants