From e1c8b07fa5ee8bc412f8b23fde13999dbba455c6 Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Fri, 8 Apr 2022 17:41:23 +1000 Subject: [PATCH] checker/tests: format test added in prev commit & rename chekcer prop --- vlib/v/checker/checker.v | 4 ++-- vlib/v/checker/comptime.v | 2 +- vlib/v/tests/comptime_call_tmpl_variable_scope_test.v | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 9ea39054b2..17a8e0429f 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -124,7 +124,7 @@ mut: inside_println_arg bool inside_decl_rhs bool inside_if_guard bool // true inside the guard condition of `if x := opt() {}` - vweb_comptime_call_pos int // needed for correctly checking use before decl for vweb templates + comptime_call_pos int // needed for correctly checking use before decl for templates } pub fn new_checker(table &ast.Table, pref &pref.Preferences) &Checker { @@ -3109,7 +3109,7 @@ pub fn (mut c Checker) ident(mut node ast.Ident) ast.Type { // if the variable is declared before the comptime call then we can assume all is well. // `node.name !in node.scope.objects` checks it's an inherited var (not defined in the tmpl). node_pos := if c.pref.is_vweb && node.name !in node.scope.objects { - c.vweb_comptime_call_pos + c.comptime_call_pos } else { node.pos.pos } diff --git a/vlib/v/checker/comptime.v b/vlib/v/checker/comptime.v index aff684ef00..49db3f5265 100644 --- a/vlib/v/checker/comptime.v +++ b/vlib/v/checker/comptime.v @@ -36,7 +36,7 @@ fn (mut c Checker) comptime_call(mut node ast.ComptimeCall) ast.Type { is_vweb: true } mut c2 := new_checker(c.table, pref2) - c2.vweb_comptime_call_pos = node.pos.pos + c2.comptime_call_pos = node.pos.pos c2.check(node.vweb_tmpl) c.warnings << c2.warnings c.errors << c2.errors diff --git a/vlib/v/tests/comptime_call_tmpl_variable_scope_test.v b/vlib/v/tests/comptime_call_tmpl_variable_scope_test.v index 18db0e9a2b..90f9bf3b4b 100644 --- a/vlib/v/tests/comptime_call_tmpl_variable_scope_test.v +++ b/vlib/v/tests/comptime_call_tmpl_variable_scope_test.v @@ -3,9 +3,11 @@ struct MyHeapStruct { name string } -// make sure dereferencing of heap stucts works in selector expr (in tmpl), +// make sure dereferencing of heap stucts works in selector expr (in tmpl), fn test_heap_struct_dereferencing_in_selector_expr() { - a := MyHeapStruct{name: 'my_heap_struct_a'} + a := MyHeapStruct{ + name: 'my_heap_struct_a' + } b := 2 $tmpl('comptime_call_tmpl_variable_scope_test.tpl') }