You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:**
Fixesedubart#277 - Incorrect line and line number for syntax error.
edubart#277
Bug description
Incorrect line and line number for syntax error
Code example
print(
Expected behavior
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
The text was updated successfully, but these errors were encountered: