v icon indicating copy to clipboard operation
v copied to clipboard

`-g` incorrect line number pointed by backtrace

Open ghost opened this issue 3 years ago • 3 comments

V version: OS:

What did you do?

struct Foo{}

fn (f Foo) foo() int{
	return 1
}

fn new_foo() ?Foo{
	return none
}

fn main(){
	i := new_foo()?.foo()
	println(i)
}

What did you expect to see? Same line number as v-panic points to.

What did you see instead?

> v -g run bug.v
================ V panic ================
   module: main
 function: main()
  message: 
     file: bug.v:12
   v hash: f922ed0
=========================================
/tmp/v_1000/../../../../../../home/tsukasa/lang/v/vlib/builtin/builtin.c.v:53: at panic_debug: Backtrace
/tmp/v_1000/../../../../../../home/tsukasa/develop/vprojects/bugs/bug.v:14: by main__main
/tmp/v_1000/../../../../../../tmp/v_1000/bug.14193986803126841185.tmp.c:17328: by main

here it says bug.v:14 although v panic says file: bug.v:12

/tmp/v_1000/../../../../../../home/tsukasa/develop/vprojects/bugs/bug.v:14: by main__main

ghost avatar Sep 16 '22 05:09 ghost

@ghost I saw that you referenced this issue in the task above. I could only see one item not checked there, but not related to this issue. The V compiler (v0.4.5) still reports the error on line 14 as before. This has not been fixed, correct?

hholst80 avatar Apr 11 '24 21:04 hholst80

@ghost I saw that you referenced this issue in the task above. I could only see one item not checked there, but not related to this issue. The V compiler (v0.4.5) still reports the error on line 14 as before. This has not been fixed, correct?

He likely won't answer. It's a placeholder account for deleted users.

ttytm avatar Apr 11 '24 22:04 ttytm

builtin.c.v:53 is where it calls backtrace, so bug.v:14 means the backtrace was called at the end of main (since that's the line number of the closing } for main).

Definite cause is trying to call .foo() on the return of none, but V really shouldn't be failing like that.

JalonSolov avatar Apr 11 '24 22:04 JalonSolov