Skip to content

Comments

fix: preserve leading nil in stab clause body#120

Open
mkaput wants to merge 1 commit intoelixir-tools:mainfrom
mkaput:pr/00034aee-leading-nil-stab
Open

fix: preserve leading nil in stab clause body#120
mkaput wants to merge 1 commit intoelixir-tools:mainfrom
mkaput:pr/00034aee-leading-nil-stab

Conversation

@mkaput
Copy link
Contributor

@mkaput mkaput commented Feb 20, 2026

A -> clause body can begin with a semicolon token after optional newlines, and that semicolon represents an implicit leading nil expression in the clause rhs.

The previous detection logic did not recognize the -> \n;expr shape reliably, so the resulting AST dropped that leading nil and diverged from Code.string_to_quoted/2 output in with ... else clauses.

This change detects the leading semicolon by peeking past end-of-line trivia before consuming clause eoe tokens, preserving the expected rhs shape.

A regression assertion was added to property test regression cases for with x <- 1 do :ok else _ -> \n;a end to prevent this AST mismatch from returning.

fix #113

A -> clause body can begin with a semicolon token after optional newlines, and that semicolon represents an implicit leading nil expression in the clause rhs.

The previous detection logic did not recognize the `-> \n;expr` shape reliably, so the resulting AST dropped that leading nil and diverged from Code.string_to_quoted/2 output in with ... else clauses.

This change detects the leading semicolon by peeking past end-of-line trivia before consuming clause eoe tokens, preserving the expected rhs shape.

A regression assertion was added to `property test regression cases` for `with x <- 1 do :ok else _ -> \n;a end` to prevent this AST mismatch from returning.

fix elixir-tools#113
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.

with x <- 1 do :ok else _ -> \n;a end

1 participant