Skip to content

Fix precendence of +: slicing op#5483

Open
ChrisDodd wants to merge 1 commit intop4lang:mainfrom
ChrisDodd:cdodd-pluscolonprec
Open

Fix precendence of +: slicing op#5483
ChrisDodd wants to merge 1 commit intop4lang:mainfrom
ChrisDodd:cdodd-pluscolonprec

Conversation

@ChrisDodd
Copy link
Contributor

@ChrisDodd ChrisDodd commented Feb 17, 2026

Since it was parsing +: as two tokens, that caused the effective precedence to be that of +. So if you tried to something like
somevar[val & 0x3f +: 1]
to mask a value and get the corresponding bit, it would give a syntax error on the :. Problem could be worked around by adding parens, but they should not be necessary.

This change also requires the +: be together (no space between them), which is not stated explicitly in the spec, but is implied that it is a single token, like other multichar tokens.

@ChrisDodd ChrisDodd requested a review from fruffy February 17, 2026 22:48
@fruffy
Copy link
Collaborator

fruffy commented Feb 17, 2026

Test for this would be nice. This way we can make sure other tools can be tested on these syntax details.

@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Topics concerning the core segments of the compiler (frontend, midend, parser)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants