Skip to content

Conversation

@doorgan
Copy link
Contributor

@doorgan doorgan commented Jan 30, 2026

We were assuming that a third integer element in the token tuple were always newlines, but they can sometimes be other things, like a delimiter character codepoint.

This caused the :newlines metadata to be attached to nodes that should not have it. This caused a mismatch between what Spitfire produces and what the Elixir parser produces.

%Foo{"ok": 1} was the smallest example I found to trigger this bug.

We were assuming that a third integer element in the token tuple were
always newlines, but they can sometimes be other things, like a
delimiter character codepoint.

This caused the `:newlines` metadata to be attached to nodes that should
not have it. This caused a mismatch between what Spitfire produces and
what the Elixir parser produces.

`%Foo{"ok": 1}` was the smallest example I found to trigger this bug.
end

defp current_newlines(%{current_token: {_token, {_line, _col, newlines}, _}}) when is_integer(newlines) do
@newline_carrying_tokens [
Copy link
Contributor Author

@doorgan doorgan Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this list by inspecting the tokenizer. Some tokens are handled directly(eg eol), most of them are handled indirectly by handle_op where previous_was_eol embeds the newlines into them.

@mhanberg mhanberg merged commit edba800 into elixir-tools:main Jan 30, 2026
37 checks passed
mhanberg pushed a commit that referenced this pull request Feb 4, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.3.2](v0.3.1...v0.3.2)
(2026-02-01)


### Bug Fixes

* associativity in bracketless kw list
([#89](#89))
([91b5d5b](91b5d5b))
* extract newlines only from newline carrying tokens
([#86](#86))
([edba800](edba800))
* improve handling of matched/unmatched expressions
([#88](#88))
([dd45cb1](dd45cb1))
* keyword list associativity
([#85](#85))
([a7d2a54](a7d2a54))
* parse ellipsis_op as unary operator
([#83](#83))
([e86f1f4](e86f1f4))
* rearrange `!(left) in right`
([#91](#91))
([fae2579](fae2579))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants