Skip to content

[Beam] Unify receive overloads and fix String.Compare codegen#4363

Merged
dbrattli merged 1 commit intomainfrom
dbrattli/beam-receive-overloads
Feb 25, 2026
Merged

[Beam] Unify receive overloads and fix String.Compare codegen#4363
dbrattli merged 1 commit intomainfrom
dbrattli/beam-receive-overloads

Conversation

@dbrattli
Copy link
Copy Markdown
Collaborator

@dbrattli dbrattli commented Feb 25, 2026

Summary

  • Erlang.receive overloads: Changed Erlang from a module with receive/receiveForever to a type with overloaded static receive methods — receive<'T>(timeoutMs) returns 'T option, receive<'T>() blocks forever and returns 'T
  • String.Compare fix: Moved comparison type dispatch from inline emitted Erlang case expressions to a new fable_string:compare/3 library function, eliminating erlc warnings about unreachable clauses caused by mixing boolean and integer patterns in the same case expression
  • The new compare/3 handles all StringComparison ignore-case variants (1, 3, 5) plus the true boolean overload via Erlang pattern matching

Test plan

  • Verify existing Beam interop tests pass (./build.sh test beam)
  • Check that the string_tests.erl "clause cannot match" warnings are gone

🤖 Generated with Claude Code

Change Erlang.receive from two separate functions (receive/receiveForever) to
overloaded static methods on a type, and move String.Compare dispatch from
inline emitted case expressions to a fable_string:compare/3 library function
to eliminate Erlang compiler warnings about unreachable clauses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dbrattli dbrattli merged commit ad6884a into main Feb 25, 2026
23 checks passed
@dbrattli dbrattli deleted the dbrattli/beam-receive-overloads branch February 25, 2026 16:24
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