Skip to content

fix: #1941 commit to named arguments once the first one starts, so a typo inside the list is reported where it is - #2231

Open
sherenkov wants to merge 1 commit into
objectionary:masterfrom
sherenkov:bug/#1941/named-args-error
Open

sherenkov wants to merge 1 commit into
objectionary:masterfrom
sherenkov:bug/#1941/named-args-error

Conversation

@sherenkov

@sherenkov sherenkov commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

An application read its whole list of named arguments inside one try, so a failure anywhere in the list backtracked into the positional form, which then failed at the first ↦. A ) forgotten on line 6 of the program in #1941 was blamed on line 3, at the ↦ of text, which is valid code.

exTail now only looks ahead for the start of a named argument, an attribute or an α index followed by ↦, and once it sees one it parses the rest of the list without backtracking. The program of #1941 is now reported at 7:10, the ↦ of mode, the first token after the missing ) that cannot be read. ⟦ a ↦ Φ.foo( x ↦ 1, y ↦ ) ⟧ is reported at the empty value of y, and ⟦ a ↦ Φ.foo( x ↦ 1, 2 ) ⟧ at the 2, both instead of at the ↦ after x. Since #2259 an argument takes no inline voids, so the lookahead takes none either.

A ParserSpec block checks the three positions and fails without the change. A case in "parse applications with mixed bindings" checks that Q.f(b(c), d), a nested call, stays positional.

Fixes #1941

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark comparison

Median of 5 round(s) per side, interleaved on the same runner against the PR merge-base, with the bench fixture frozen across both builds. Noise is the spread between the fastest and the slowest round, taken from the noisier side.

Bench base (μs) head (μs) delta noise
morph/symbolic/accum/0 113.52 110.66 -2.5% ±3.0%
morph/symbolic/accum/400 133.57 131.41 -1.6% ±2.5%
morph/symbolic/demo/e1 132.29 131.36 -0.7% ±4.1%
morph/symbolic/demo/e2 134.16 131.59 -1.9% ±2.7%
morph/symbolic/demo/e3 134.48 132.30 -1.6% ±2.2%
morph/symbolic/demo/e4 135.09 131.03 -3.0% ±3.6%
morph/symbolic/demo/e5 137.00 133.04 -2.9% ±1.5%
morph/symbolic/native/e5 1190.42 1156.20 -2.9% ±43.1%
parse/phi 235516.49 234518.38 -0.4% ±1.7%
parse/xmir 948534.77 936682.03 -1.2% ±1.4%
print/salty/multiline 1782052.91 1771902.90 -0.6% ±2.9%
print/sweet/flat 68942.15 66033.29 -4.2% ±5.6%
print/sweet/multiline 535855.58 537550.94 +0.3% ±3.5%
rewrite/normalize 2.15 2.09 -3.0% ±5.3%

Scaling

Each sized case against its /0 sibling, the same work over nothing extra: a ratio near 1 means the extra size is free.

Bench against base head
morph/symbolic/accum/400 morph/symbolic/accum/0 1.18× 1.19×

No case moved by more than 20% beyond its own noise.
This report is informational, a delta never fails the build.

@sherenkov

Copy link
Copy Markdown
Contributor Author

@yegor256 CI is green and the branch is up to date with master, could you take a look when you have a moment? As you suggested in #1941, try now covers only the lookahead for the start of a named argument, so the program of the report is blamed at line 7, right after the missing ), instead of at the first ↦ on line 3, and ParserSpec checks that position.

@sherenkov
sherenkov force-pushed the bug/#1941/named-args-error branch 6 times, most recently from d9724da to cf72d5d Compare November 5, 2026 09:13
@sherenkov

Copy link
Copy Markdown
Contributor Author

@yegor256 CI is green and the branch is up to date with master, could you take a look when you have a moment? Since #2259 refused inline voids in an argument, the lookahead for a named argument takes none either, so it reads exactly the start argument reads, and a typo inside the list of #1941 is still reported where it is.

@sherenkov
sherenkov force-pushed the bug/#1941/named-args-error branch 4 times, most recently from 3d29443 to e7cfc13 Compare November 6, 2026 09:02

@yegor256 yegor256 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The parser commits to named arguments only after lookahead sees an attribute or index followed by an arrow. Tests pin the improved error locations and retain nested positional calls.

@sherenkov
sherenkov force-pushed the bug/#1941/named-args-error branch from 84344af to 2df9b97 Compare November 6, 2026 21:03
…tarts, so a typo inside the list is reported where it is
@sherenkov
sherenkov force-pushed the bug/#1941/named-args-error branch from 2df9b97 to ba1ceee Compare November 7, 2026 09:11

This branch has not been deployed

No deployments
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.

A typo inside a named argument is reported at the first argument's ↦, so a missing ) on line 6 is blamed on line 3 (src/Parser.hs:512)

2 participants