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

Double counting of CRLF newline seq in metadata #1063

Closed
ikappaki opened this issue Sep 19, 2024 · 0 comments · Fixed by #1064
Closed

Double counting of CRLF newline seq in metadata #1063

ikappaki opened this issue Sep 19, 2024 · 0 comments · Fixed by #1064
Labels
component:reader Issue pertaining to Basilisp reader module issue-type:bug Something isn't working

Comments

@ikappaki
Copy link
Contributor

Hi,

t appears that the CRLF newline sequence is being double counted when calculating the line number in the metadata.

To reproduce

  1. Open up the basilisp REPL, evaluate a string that defines a variable after a single CRLF sequence, and then retrieve the metadata.a. The :line number in the meta is 3, instead of 2
> basilisp repl
basilisp.user=> (load-string "\r\n(def crlf 123)")
#'basilisp.user/crlf

basilisp.user=> (meta #'crlf)
{:line 3 :col 0 :ns basilisp.user :end-col 14 :end-line 3 :file "<Load Input>" :name crlf}

For comparison, using a single newline character reports the correct line number:

basilisp.user=> (meta #'n)
{:line 2 :col 0 :ns basilisp.user :end-col 11 :end-line 2 :file "<Load Input>" :name n}

PR to follow.
Thanks

@chrisrink10 chrisrink10 added issue-type:bug Something isn't working component:reader Issue pertaining to Basilisp reader module labels Sep 19, 2024
chrisrink10 pushed a commit that referenced this issue Sep 19, 2024
…1064)

Hi,

can you please a fix for the line number in the metadata generated by
the reader. It fixes #1063.

We now check the char at -2 only if it’s:
-  `\n` (for `\nC` or `\r\nC` case)
-  `\r` (for the `\rC`, but not `\r\n`, case).

where `C` is any other char.

Added tests for the same.

Thanks

---------

Co-authored-by: ikappaki <ikappaki@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:reader Issue pertaining to Basilisp reader module issue-type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants