Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect line and line number for syntax error #277

Open
kmafeni04 opened this issue Nov 4, 2024 · 0 comments · May be fixed by #288
Open

incorrect line and line number for syntax error #277

kmafeni04 opened this issue Nov 4, 2024 · 0 comments · May be fixed by #288
Labels

Comments

@kmafeni04
Copy link

kmafeni04 commented Nov 4, 2024

Bug description

Incorrect line and line number for syntax error

nelua test.nelua
test.nelua:2:0: syntax error: unclosed parenthesis, did you forget a `)`?

^

Code example

print(

Expected behavior

nelua test.nelua
test.nelua:1:6: syntax error: unclosed parenthesis, did you forget a `)`?

^

Workaround

If you have already found a way to workaround the issue,
then please share how you did it,
this may help others with the same issue.

Environment

Nelua 0.2.0-dev
Arch Linux
x86_64
gcc

@kmafeni04 kmafeni04 added the bug label Nov 4, 2024
DeanHnter added a commit to DeanHnter/nelua-lang that referenced this issue Jan 9, 2025
Fix `lpegrex.calcline` to Correctly Compute Line and Column Numbers

**Functionality Changes:**
- **Position Capping:** Ensured that the `position` does not exceed the length of `subject` by using `math.min(position, #subject)` instead of an `if` statement. This prevents potential out-of-bounds errors.
- **Column Number Calculation:** Updated the logic to accurately calculate the column number. If the calculated `colno` is `0`, it now correctly assigns `position` as the column number, ensuring accurate reporting at line boundaries.
- **Line End Handling:** Improved the determination of `lineend` by providing a fallback to `#subject + 1` when a newline character is not found. This ensures the entire line is captured correctly, especially for the last line in the `subject`.

**Issue:**
Fixes edubart#277 - Incorrect line and line number for syntax error.
edubart#277
@DeanHnter DeanHnter linked a pull request Jan 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant