tree-sitter / tree-sitter-julia

Julia grammar for Tree-sitter
MIT License
93 stars 31 forks source link

string literal juxtaposition shouldnt be allowed #116

Open vdayanand opened 11 months ago

vdayanand commented 11 months ago

1"test" is not a valid syntax but is allowed

(source_file [0, 0] - [1, 0]
  (juxtaposition_expression [0, 0] - [0, 4]
    (integer_literal [0, 0] - [0, 1])
    (string_literal [0, 1] - [0, 4])))

in julia

julia> 1"test"
ERROR: syntax: cannot juxtapose string literal
Stacktrace:
 [1] top-level scope
   @ none:1
fredrikekre commented 1 month ago

I believe this bug messes with docstring parsing/detection too, e.g. I had something like

x = 1

"""
docs
"""
function f(x)
    # body
end

which parses as

(assignment) ; [1:1 - 5:3]
 (identifier) ; [1:1 - 1]
 (operator) ; [1:3 - 3]
 (juxtaposition_expression) ; [1:5 - 5:3]
  (integer_literal) ; [1:5 - 5]
  (string_literal) ; [3:1 - 5:3]
(function_definition) ; [6:1 - 8:3]
 (signature) ; [6:10 - 13]
  (call_expression) ; [6:10 - 13]
   (identifier) ; [6:10 - 10]
   (argument_list) ; [6:11 - 13]
    (identifier) ; [6:12 - 12]
 (line_comment) ; [7:5 - 10]