checker/tests: format test added in prev commit & rename chekcer prop

pull/13971/head
Joe Conigliaro 2022-04-08 17:41:23 +10:00
parent 8dc2601080
commit e1c8b07fa5
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
3 changed files with 7 additions and 5 deletions

View File

@ -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
}

View File

@ -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

View File

@ -5,7 +5,9 @@ struct MyHeapStruct {
// 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')
}