Skip to content

fix: correct named unary arithmetic precedence - #1309

Merged
fglock merged 2 commits into
masterfrom
fix/issue-1259-prefix-not-modulo
Sep 8, 2026
Merged

fix: correct named unary arithmetic precedence#1309
fglock merged 2 commits into
masterfrom
fix/issue-1259-prefix-not-modulo

Conversation

@fglock

@fglock fglock commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Parse scalar operands at the named-unary precedence boundary, restoring the documented behavior of ! scalar @array % 2.
  • Retain the aggregate operand boundary for keys, values, and each; this fixes UAT’s keys(%benchmarks) * 4 compile regression.
  • Add permanent project-owned precedence coverage for both expressions on the JVM and interpreter backends.

Fixes #1259

Validation

  • prove src/test/resources/unit/precedence.t (system Perl, 18 tests)
  • ./jperl src/test/resources/unit/precedence.t (18 tests)
  • ./jperl --interpreter src/test/resources/unit/precedence.t (18 tests)
  • cd perl5_t/t && ../../jperl perf/benchmarks.t (6,648 checks)
  • make after the UAT regression correction
  • GitHub Actions for follow-up commit 49e8abb00

Generated with Codex

fglock and others added 2 commits September 8, 2026 16:47
Parse the operand of scalar, values, keys, and each at the named-unary
boundary so arithmetic binds inside it. This restores the expected grouping
of ! scalar @array % 2 used by Class::MakeMethods.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Restrict scalar's relaxed arithmetic operand boundary to scalar. keys,
values, and each keep their aggregate operand boundary, restoring expressions
such as keys(%hash) * 4 used by perf/benchmarks.t.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
@fglock
fglock marked this pull request as ready for review September 8, 2026 18:09
@fglock
fglock merged commit 9e34d82 into master Sep 8, 2026
2 checks passed
@fglock
fglock deleted the fix/issue-1259-prefix-not-modulo branch September 8, 2026 18:09
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.

Fix operator precedence for prefix ! and modulo %

1 participant