Skip to content

fix: suffix Httpc Emit variables to avoid Erlang scope collisions#20

Merged
dbrattli merged 1 commit intomainfrom
fix/httpc-variable-scoping
Mar 21, 2026
Merged

fix: suffix Httpc Emit variables to avoid Erlang scope collisions#20
dbrattli merged 1 commit intomainfrom
fix/httpc-variable-scoping

Conversation

@dbrattli
Copy link
Collaborator

Summary

  • Suffix all internal variables in Httpc Emit blocks with __0 (e.g. UrlUrl__0, BodyBody__0) to prevent collisions with caller-scope variables, since Erlang's = is pattern matching, not rebinding
  • Update comments to accurately explain why IIFEs and suffixed variables are needed

Test plan

  • Verify Fable compiles the module without errors
  • Confirm generated Erlang uses the suffixed variable names
  • Test HTTP requests (GET, POST, PUT, DELETE) still work correctly

🤖 Generated with Claude Code

Erlang's = is pattern matching, not rebinding. When Fable inlines Emit
expressions, internal variable names like Url or Body can collide with
variables in the caller's scope. Suffix all internal variables with __0
to prevent these collisions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dbrattli dbrattli merged commit c050d67 into main Mar 21, 2026
2 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.

1 participant