Skip to content

parser,checker: vls fix goto definition#25595

Merged
spytheman merged 3 commits intovlang:masterfrom
kbkpbot:vls-fix-goto-definition
Oct 27, 2025
Merged

parser,checker: vls fix goto definition#25595
spytheman merged 3 commits intovlang:masterfrom
kbkpbot:vls-fix-goto-definition

Conversation

@kbkpbot
Copy link
Contributor

@kbkpbot kbkpbot commented Oct 26, 2025

@Avey777 Avey777 mentioned this pull request Oct 26, 2025
@spytheman
Copy link
Contributor

spytheman commented Oct 26, 2025

On master, I can do:
v -vls-mode -line-info "examples/hello_world.v:1:gd^println" examples/hello_world.v
and get /home/delian/v/vlib/builtin/builtin.c.v:326:0 in return, and I can jump to that location with my editor.

How can I do the same here? The same command on this PR panics.

#0 10:08:41 ^ vls-fix-goto-definition ~/v>v -vls-mode  -line-info "examples/hello_world.v:1:gd^println" examples/hello_world.v
================ V panic ================
   module: v.ast
 function: default_table_panic_handler()
  message: table.sym: invalid type (typ=ast.Type(0x0 = 0) idx=0). Compiler bug. This should never happen. Please report the bug using `v bug file.v`.

     file: /home/delian/v/vlib/v/ast/table.v:150
   v hash: 24f2f4f
=========================================
/home/delian/v/vlib/builtin/builtin.c.v:88: at builtin__panic_debug: Backtrace
/home/delian/v/vlib/v/ast/table.v:150: by v__ast__default_table_panic_handler
/home/delian/v/vlib/v/ast/table.v:156: by v__ast__Table_panic
/home/delian/v/vlib/v/ast/table.v:777: by v__ast__Table_sym
/home/delian/v/vlib/v/gen/c/cgen.v:1696: by v__gen__c__Gen_cc_type
/home/delian/v/vlib/v/gen/c/cgen.v:1284: by v__gen__c__Gen_base_type
/home/delian/v/vlib/v/gen/c/cgen.v:1261: by v__gen__c__Gen_styp
/home/delian/v/vlib/v/gen/c/consts_and_globals.v:316: by v__gen__c__Gen_const_decl_init_later
/home/delian/v/vlib/v/gen/c/consts_and_globals.v:126: by v__gen__c__Gen_const_decl
/home/delian/v/vlib/v/gen/c/cgen.v:2567: by v__gen__c__Gen_stmt
/home/delian/v/vlib/v/gen/c/cgen.v:2284: by v__gen__c__Gen_stmts_with_tmp_var
/home/delian/v/vlib/v/gen/c/cgen.v:2121: by v__gen__c__Gen_stmts
/home/delian/v/vlib/v/gen/c/cgen.v:934: by v__gen__c__Gen_gen_file
/home/delian/v/vlib/v/gen/c/cgen.v:496: by v__gen__c__gen
/home/delian/v/vlib/v/builder/cbuilder/cbuilder.v:80: by v__builder__cbuilder__gen_c
/home/delian/v/vlib/v/builder/cbuilder/cbuilder.v:60: by v__builder__cbuilder__build_c
/home/delian/v/vlib/v/builder/cbuilder/cbuilder.v:50: by v__builder__cbuilder__compile_c
/home/delian/v/vlib/v/builder/rebuilding.v:326: by v__builder__Builder_rebuild
/home/delian/v/vlib/v/builder/compile.v:17: by v__builder__compile
/home/delian/v/cmd/v/v.v:211: by main__rebuild
/home/delian/v/cmd/v/v.v:169: by main__main
/home/delian/v/vlib/builtin/closure/closure.c.v:860: by main
#1 10:08:42 ^ vls-fix-goto-definition ~/v>

Adding -check too, prevents the panic, but does not produce any result either:

#1 10:08:42 ^ vls-fix-goto-definition ~/v>v -check -vls-mode  -line-info "examples/hello_world.v:1:gd^println" examples/hello_world.v
#0 10:09:36 ^ vls-fix-goto-definition ~/v>

@kbkpbot
Copy link
Contributor Author

kbkpbot commented Oct 26, 2025

On master, I can do: v -vls-mode -line-info "examples/hello_world.v:1:gd^println" examples/hello_world.v and get /home/delian/v/vlib/builtin/builtin.c.v:326:0 in return, and I can jump to that location with my editor.

How can I do the same here? The same command on this PR panics.

#0 10:08:41 ^ vls-fix-goto-definition ~/v>v -vls-mode  -line-info "examples/hello_world.v:1:gd^println" examples/hello_world.v
================ V panic ================
   module: v.ast
 function: default_table_panic_handler()
  message: table.sym: invalid type (typ=ast.Type(0x0 = 0) idx=0). Compiler bug. This should never happen. Please report the bug using `v bug file.v`.

     file: /home/delian/v/vlib/v/ast/table.v:150
   v hash: 24f2f4f
=========================================
/home/delian/v/vlib/builtin/builtin.c.v:88: at builtin__panic_debug: Backtrace
/home/delian/v/vlib/v/ast/table.v:150: by v__ast__default_table_panic_handler
/home/delian/v/vlib/v/ast/table.v:156: by v__ast__Table_panic
/home/delian/v/vlib/v/ast/table.v:777: by v__ast__Table_sym
/home/delian/v/vlib/v/gen/c/cgen.v:1696: by v__gen__c__Gen_cc_type
/home/delian/v/vlib/v/gen/c/cgen.v:1284: by v__gen__c__Gen_base_type
/home/delian/v/vlib/v/gen/c/cgen.v:1261: by v__gen__c__Gen_styp
/home/delian/v/vlib/v/gen/c/consts_and_globals.v:316: by v__gen__c__Gen_const_decl_init_later
/home/delian/v/vlib/v/gen/c/consts_and_globals.v:126: by v__gen__c__Gen_const_decl
/home/delian/v/vlib/v/gen/c/cgen.v:2567: by v__gen__c__Gen_stmt
/home/delian/v/vlib/v/gen/c/cgen.v:2284: by v__gen__c__Gen_stmts_with_tmp_var
/home/delian/v/vlib/v/gen/c/cgen.v:2121: by v__gen__c__Gen_stmts
/home/delian/v/vlib/v/gen/c/cgen.v:934: by v__gen__c__Gen_gen_file
/home/delian/v/vlib/v/gen/c/cgen.v:496: by v__gen__c__gen
/home/delian/v/vlib/v/builder/cbuilder/cbuilder.v:80: by v__builder__cbuilder__gen_c
/home/delian/v/vlib/v/builder/cbuilder/cbuilder.v:60: by v__builder__cbuilder__build_c
/home/delian/v/vlib/v/builder/cbuilder/cbuilder.v:50: by v__builder__cbuilder__compile_c
/home/delian/v/vlib/v/builder/rebuilding.v:326: by v__builder__Builder_rebuild
/home/delian/v/vlib/v/builder/compile.v:17: by v__builder__compile
/home/delian/v/cmd/v/v.v:211: by main__rebuild
/home/delian/v/cmd/v/v.v:169: by main__main
/home/delian/v/vlib/builtin/closure/closure.c.v:860: by main
#1 10:08:42 ^ vls-fix-goto-definition ~/v>

Adding -check too, prevents the panic, but does not produce any result either:

#1 10:08:42 ^ vls-fix-goto-definition ~/v>v -check -vls-mode  -line-info "examples/hello_world.v:1:gd^println" examples/hello_world.v
#0 10:09:36 ^ vls-fix-goto-definition ~/v>

This PR should work with the vls PR vlang/vls#470

Original vls send a gd^println to v, but I think it is not enough. So I changed it to send the column info instead, something like gd^6. This will help find out which indent is the right one by compare it's pos's line_nr and col, not by string compare.

$ v -vls-mode -line-info "examples/hello_world.v:0:gd^1" examples/hello_world.v
{"uri":"/media/HD/github/kbkpbot/v/vlib/builtin/builtin.c.v","range":{"start":{"line":326,"character":7},"end":{"line":326,"character":7}}}

@spytheman
Copy link
Contributor

spytheman commented Oct 26, 2025

Is there an easy way to restore the ability to output just the file:line:col information on this PR?
(i.e. given source_file:source_line:source_col -> definition_file:definition_line)

Copy link
Contributor

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thank you @kbkpbot.

@spytheman
Copy link
Contributor

This v -check -vls-mode -line-info "examples/hello_world.v:1:gd^println" examples/hello_world.v still does not work here, but I'll fix soon.

@spytheman
Copy link
Contributor

hm, it works with:
v -vls-mode -line-info "examples/hello_world.v:1:gd^5" examples/hello_world.v so it may be fine 🤔

@spytheman
Copy link
Contributor

spytheman commented Oct 27, 2025

These lead to a cgen panic:

  • v -vls-mode -line-info "examples/hello_world.v:1:gd^0" examples/hello_world.v
  • v -vls-mode -line-info "examples/hello_world.v:1:gd^100" examples/hello_world.v

so the -check is needed now 🤔.

@spytheman spytheman merged commit 940f2c5 into vlang:master Oct 27, 2025
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants