tree-sitter / tree-sitter-python

Python grammar for tree-sitter
MIT License
360 stars 132 forks source link

bug: `.1l` is not valid in python2 #259

Closed Eloitor closed 6 months ago

Eloitor commented 6 months ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter 0.21.0

Describe the bug

.1l or .1L is not valid in python2.

Test: https://github.com/tree-sitter/tree-sitter-python/blob/22d3f87bdafac2782e907330babe4af574f5d0b4/test/corpus/literals.txt#L63C1-L64

Source: https://github.com/tree-sitter/tree-sitter-python/blob/22d3f87bdafac2782e907330babe4af574f5d0b4/grammar.js#L1160

Solution: I think that changing that line to optional(/[jJ]/) is needed.

Steps To Reproduce/Bad Parse Tree

  1. Open python2
  2. Write .1l

Expected Behavior/Parse Tree

.1l in the test/corpus/literals.txt fails to parse.

Repro

.1l
ObserverOfTime commented 6 months ago

Or maybe you could stop using Python 2.

Eloitor commented 6 months ago

It is not valid in python3 either...

amaanq commented 6 months ago

It's valid in python2 but not for floats