run: parse-error line numbers offset by prepended stdlib (+32) #18
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-prolog#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
patch-prolog runreports parse-error line numbers relative to the internally assembled source (stdlib + user files concatenated), not the user's file. Every reported line is shifted by the length ofstdlib.pl(+1 for the joining newline) — currently +32.Repro
A two-line file
/tmp/op.pl:The error is on the user's line 2, but is reported as line 33. A one-line file reports the error around line 32–33, i.e. past EOF of what the user is looking at.
Cause
src/runner.rs::assemble_source()prependsknowledge/stdlib.pl(31 lines) +'\n'to the user's file content and parses the combined string, so parser line numbers are offset by the stdlib length.knowledge/stdlib.plis 31 lines → offset is +32.Impact
Learner-facing tooling (loglings) surfaces this error text verbatim. A beginner whose typo is on their line 5 is told "line 37" — past the end of their file. This makes the single most common error (a syntax slip) effectively impossible to locate from the message.
Suggested fix
Parse
stdlib.plas its own unit, or carry a per-source line offset and subtract the stdlib length before reporting (and ideally attach the originating filename to the span).Found while building the
loglingsProlog exercises against the installed engine.#23
mod,],.,)— instead of Mod, RBracket, Dot, RParen. #25