fix: upgrade to Fable 5.13 and Fable.Beam rc.34, emit real atoms - #38
Merged
Conversation
Fable.Beam rc.34 makes the `Atom` union constructor private. Because `Atom` is `[<Erase>]`d, the previous `Atom "debug"` compiled to the *binary* `<<"debug"/utf8>>` rather than to an atom, so `logger:set_primary_config(<<"level">>, <<"debug">>)` was passing binaries where OTP expects atoms and the primary log level was never actually set (the result is `|> ignore`d, so it failed silently). All 7 call sites now use `Atom.ofString`, which emits `erlang:binary_to_atom(<<"debug"/utf8>>)`. Also wires up BEAM test execution, which is what allowed this to go unnoticed: `TestBeamLogger.fs` is guarded by `#if FABLE_COMPILER_BEAM`, so under `just test` (.NET) all five Beam tests compiled to `()` and passed without exercising anything. - Add `Fable.Beam` to the paket `Test` group so `test/` can transpile to Erlang at all - Add `just build-beam` / `just test-beam` (fable --lang beam -> rebar3 -> erl), following the same shape as Fable.Beam's own justfile - Run both suites in CI, which previously only built `Fable.Logging.Structlog` is excluded from the BEAM transpile: its `[<Emit>]` bodies contain literal Python (`$0.debug($1, **$2)`) which Fable emits verbatim, producing Erlang that does not parse. Verified: 49/49 on .NET, 49/49 on the BEAM under OTP 25. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades to Fable 5.13.0 and Fable.Beam 5.0.0-rc.34, and fixes a silent runtime bug the upgrade surfaced.
rc.34 makes the
Atomunion constructor private, on purpose: becauseAtomis[<Erase>]d,Atom "debug"compiled to the binary<<"debug"/utf8>>, not to an atom. So this call was passing binaries where OTP expects atoms:The result is
|> ignored, so the primary log level was silently never set. All 7 call sites now useAtom.ofString, which emitserlang:binary_to_atom(<<"debug"/utf8>>).Fable 5.13 also landed fix(beam): compile
[<StringEnum>]cases to atoms instead of binaries — same class of bug. This repo has no[<StringEnum>]usage, so nothing to change there.Why it went unnoticed
TestBeamLogger.fsis guarded by#if FABLE_COMPILER_BEAM. Underjust test(.NET) that define is off, so all five Beam tests compiled down to()and passed without exercising anything. The BEAM tests could not run at all: the paketTestgroup only declaredFSharp.CoreandFable.Core, sodotnet fable test --lang beamfailed with 14 ×namespace 'Beam' is not defined.So this PR also makes them runnable:
Fable.Beamadded to the paketTestgroup andtest/paket.referencesjust build-beam/just test-beam— fable--lang beam→rebar3 compile→erl, following the same shape as Fable.Beam's own justfileFable.Logging.Structlogis excluded from the BEAM transpile via--exclude. Its[<Emit>]bodies contain literal Python ($0.debug($1, **$2)) which Fable emits verbatim into Erlang that does not parse.TestStructlog.fsis already#if FABLE_COMPILER_PYTHON-guarded, so nothing references the excluded module.Verification
just test— 49/49 on .NETjust test-beam— 49/49 on the BEAM (locally OTP 25; CI pins OTP 27 to match Fable.Beam)just format-checkcleanerlang:binary_to_atom(...)at all call sites=INFO REPORT=,=WARNING REPORT=,=ERROR REPORT=,=CRITICAL REPORT=— which only works with genuine atomsNot addressed
Structlog.fshas no target guards, so referencingFable.Logging.Structlogfrom a JS or BEAM Fable project produces invalid output for consumers too. Guarding it with#if !FABLE_COMPILER || FABLE_COMPILER_PYTHONwould fix that at the source and make the--excludeunnecessary. Left out as a separate concern.🤖 Generated with Claude Code