diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 13cd8f510b..497ef43235 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -213,6 +213,7 @@ pub: is_builtin bool // this function is defined in builtin/strconv ctdefine string // has [if myflag] tag pos token.Position + file string pub mut: return_type table.Type } @@ -930,7 +931,7 @@ fn (stmt Stmt) position() token.Position { } // TODO: remove this fugly hack :-| -// fe2ex/1 and ex2fe/1 are used to convert back and forth from +// fe2ex/1 and ex2fe/1 are used to convert back and forth from // table.FExpr to ast.Expr , which in turn is needed to break // a dependency cycle between v.ast and v.table, for the single // field table.Field.default_expr, which should be ast.Expr diff --git a/vlib/v/gen/fn.v b/vlib/v/gen/fn.v index fd3745ad6f..23af82c276 100644 --- a/vlib/v/gen/fn.v +++ b/vlib/v/gen/fn.v @@ -479,6 +479,14 @@ fn (mut g Gen) fn_call(node ast.CallExpr) { } g.write('))') } + } else if g.pref.is_debug && node.name == 'panic' { + paline := node.pos.line_nr + 1 + pafile := g.fn_decl.file + pafn := g.fn_decl.name.after('.') + pamod := g.fn_decl.name.all_before_last('.') + g.write('panic_debug($paline, tos3("$pafile"), tos3("$pamod"), tos3("$pafn"), ') + g.call_args(node.args, node.expected_arg_types) + g.write(')') } else { g.write('${name}(') g.call_args(node.args, node.expected_arg_types) diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index f3402a0457..c0b5309b28 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -255,6 +255,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl { is_js: is_js no_body: no_body pos: start_pos.extend(end_pos) + file: p.file_name is_builtin: p.builtin_mod || p.mod in util.builtin_module_parts ctdefine: ctdefine } @@ -305,6 +306,7 @@ fn (mut p Parser) anon_fn() ast.AnonFn { is_anon: true no_body: no_body pos: pos + file: p.file_name } typ: typ } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index d5b1987dbd..cccfc1b905 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -106,6 +106,7 @@ pub fn parse_file(path string, b_table &table.Table, comments_mode scanner.Comme if p.pref.is_script && !p.pref.is_test && p.mod == 'main' && !have_fn_main(stmts) { stmts << ast.FnDecl { name: 'main' + file: p.file_name return_type: table.void_type } } diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index 90529a7d9e..950a23723b 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -286,6 +286,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl { mut method := ast.FnDecl{ name: name args: args + file: p.file_name return_type: table.void_type } if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr {