Skip to content

[Beam] Fix double-quoted atoms for uppercase CompiledName DU cases#4388

Merged
dbrattli merged 3 commits intomainfrom
dbrattli/beam-improvements-16
Mar 8, 2026
Merged

[Beam] Fix double-quoted atoms for uppercase CompiledName DU cases#4388
dbrattli merged 3 commits intomainfrom
dbrattli/beam-improvements-16

Conversation

@dbrattli
Copy link
Collaborator

@dbrattli dbrattli commented Mar 7, 2026

Summary

  • Fix double-quoting of Erlang atoms when [<CompiledName("EXIT")>] (or any uppercase name) is used on a DU case. quoteErlangAtom was called both in Fable2Beam.fs (when building the AST) and in ErlangPrinter.fs (when rendering), producing ''EXIT'' instead of 'EXIT'.
  • Fix cross-project imports with same-named source files producing infinite self-recursion. resolveImportModuleName compared derived module names (e.g., "types") to decide if an import is local. When two projects both have Types.fs, the import was incorrectly treated as a local call (e.g., empty_handle() -> empty_handle()). Fixed by comparing resolved absolute file paths instead of module names.
  • Add test for Erlang.receive with uppercase CompiledName atom tag.

Test plan

  • Existing Beam interop tests pass (lowercase CompiledName like custom_tag still works)
  • New test test Erlang receive with uppercase CompiledName atom tag passes
  • Generated .erl files use 'EXIT' (single-quoted) not ''EXIT''
  • Cross-project compilation with same-named source files produces correct remote calls instead of self-recursion

🤖 Generated with Claude Code

dbrattli and others added 3 commits March 7, 2026 15:32
quoteErlangAtom was called in Fable2Beam.fs before storing atom names
into the Atom AST node, but the printer also calls quoteErlangAtom when
rendering AtomLit. This caused uppercase atoms like EXIT to be emitted
as ''EXIT'' (double single-quotes) instead of 'EXIT'.

Fix: remove quoteErlangAtom calls from Fable2Beam.fs so quoting only
happens once at print time in ErlangPrinter.fs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
resolveImportModuleName compared derived module names (e.g., "types")
to decide if an import is local. When two projects both have Types.fs,
the import was incorrectly treated as a local call, producing infinite
self-recursion (e.g., empty_handle() -> empty_handle()).

Fix: compare resolved absolute file paths instead of module names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dbrattli dbrattli merged commit 3a21511 into main Mar 8, 2026
23 checks passed
@dbrattli dbrattli deleted the dbrattli/beam-improvements-16 branch March 8, 2026 06:17
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.

1 participant