Skip to content

checker: add error message call stack support#26356

Merged
spytheman merged 3 commits into
vlang:masterfrom
kbkpbot:checker-add-call-stack
Jan 15, 2026
Merged

checker: add error message call stack support#26356
spytheman merged 3 commits into
vlang:masterfrom
kbkpbot:checker-add-call-stack

Conversation

@kbkpbot

@kbkpbot kbkpbot commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Feature request by #16127, #24575

Currently, support $compile_error() and $tmpl call stack showing in error message:

vlib/v/checker/tests/compile_error_call_position.vv:5:3: error: son only taken int as input
    3 | fn son[T](val T) {
    4 |     $if T !is int {
    5 |         $compile_error('son only taken int as input')
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    6 |     }
    7 | }
called from vlib/v/checker/tests/compile_error_call_position.vv:10:2
    8 |
    9 | fn main() {
   10 |     son(false)
      |     ~~~~~~~~~~
   11 | }
template_call_position_test.txt:11:2: error: undefined ident: `unknown_var` (veb action: main__main)
called from vlib/v/checker/tests/template_call_position.vv:4:2
    2 |
    3 | fn main() {
    4 |     $tmpl('template_call_position_test.txt')
      |     ^
    5 | }
template_call_position_test.txt:11:2: error: expression does not return a value (veb action: main__main)
called from vlib/v/checker/tests/template_call_position.vv:4:2
    2 |
    3 | fn main() {
    4 |     $tmpl('template_call_position_test.txt')
      |     ^
    5 | }

Comment thread vlib/v/checker/check_types.v Outdated
Comment thread vlib/v/checker/tests/comptime_else_compile_error_no_return.out
@spytheman

Copy link
Copy Markdown
Contributor

Excellent work.

Can this be extended in the future, to show the callstack for errors, that happen in nested generic calls like in x.json2 ?

@spytheman

Copy link
Copy Markdown
Contributor

For example, I tried to update https://github.com/herudi/cdv to work with latest V a few days ago, but got:
image

with no easy way to know what and where was the original call that triggered each x.json2 error ...

@spytheman spytheman merged commit adcd421 into vlang:master Jan 15, 2026
85 checks passed
@kbkpbot

kbkpbot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor Author

Excellent work.

Can this be extended in the future, to show the callstack for errors, that happen in nested generic calls like in x.json2 ?

I think we can try.
I need a testcase to try. :)

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