Skip to content

Tree-sitter is giving wrong AST after file changed. #409

@SirZenith

Description

@SirZenith

System Information

V doctor

OS: windows, Microsoft Windows 11 רҵ�� v22621 64-bit
Processor: 16 cpus, 64bit, little endian, Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz  
CC version: cc (Rev6, Built by MSYS2 project) 12.2.0

getwd: C:\Users\PC\.vls\reports
vmodules: C:\Users\PC\.vmodules
vroot: F:\Programming\V\v
vexe: F:\Programming\V\v\v.exe
vexe mtime: 2022-12-22 08:16:00
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.2 3c5cfa2

Git version: git version 2.39.0.windows.2
Git vroot status: weekly.2022.50-55-g3c5cfa22 (26 commit(s) behind V master)
.git/config present: true
thirdparty/tcc status: thirdparty-windows-amd64 cb89a4fe

VLS info

vls version 0.0.1.f0aa56e

Problem Description

During file modification, Tree-sitter gives wrong AST for source code:

module main

fn main() {
	test := ''
}

Expected Output

Proper Tree-sitter AST should be:

module_clause [0, 0] - [0, 11]
  module_identifier [0, 7] - [0, 11]
function_declaration [2, 0] - [4, 1]
  name: identifier [2, 3] - [2, 7]
  parameters: parameter_list [2, 7] - [2, 9]
  body: block [2, 10] - [4, 1]
    short_var_declaration [3, 1] - [3, 11]
      left: expression_list [3, 1] - [3, 5]
        identifier [3, 1] - [3, 5]
      right: expression_list [3, 9] - [3, 11]
        interpreted_string_literal [3, 9] - [3, 11]

Actual Output

module_clause [0, 0] - [0, 11]
  module_identifier [0, 7] - [0, 11]
function_declaration [2, 0] - [4, 1]
  name: identifier [2, 3] - [2, 7]
  parameters: parameter_list [2, 7] - [2, 9]
  body: block [2, 10] - [4, 1]
    ERROR [3, 1] - [4, 0]
      expression_list [3, 1] - [3, 5]
        identifier [3, 1] - [3, 5]

Note: AST output is given by nvim-treesitter/playground plugin of Neovim.

Steps to Reproduce

You only need to modify assignment of test on line 4.

Open you file and start VLS with:

test := ''

Type whatever you like into string literal:

test := 'this'

Start deleting character you just typee one by one from the end of string literal, until the string is empty:

test := ''

Now you should see the ERROR node in AST.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions