vweb: fix unused var warning
parent
deddc71720
commit
a130d3cd14
|
@ -195,7 +195,7 @@ fn (mut c Checker) check_file_in_main(file ast.File) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut c Checker) check_valid_snake_case(name, identifier string, pos token.Position) {
|
fn (mut c Checker) check_valid_snake_case(name, identifier string, pos token.Position) {
|
||||||
if name[0] == `_` {
|
if name[0] == `_` && !c.pref.is_vweb {
|
||||||
c.error('$identifier `$name` cannot start with `_`', pos)
|
c.error('$identifier `$name` cannot start with `_`', pos)
|
||||||
}
|
}
|
||||||
if util.contains_capital(name) {
|
if util.contains_capital(name) {
|
||||||
|
@ -1765,14 +1765,14 @@ pub fn (c &Checker) unwrap_generic(typ table.Type) table.Type {
|
||||||
|
|
||||||
// TODO node must be mut
|
// TODO node must be mut
|
||||||
pub fn (mut c Checker) expr(node ast.Expr) table.Type {
|
pub fn (mut c Checker) expr(node ast.Expr) table.Type {
|
||||||
|
|
||||||
c.expr_level++
|
c.expr_level++
|
||||||
defer { c.expr_level -- }
|
defer {
|
||||||
|
c.expr_level--
|
||||||
|
}
|
||||||
if c.expr_level > 200 {
|
if c.expr_level > 200 {
|
||||||
c.error('checker: too many expr levels: $c.expr_level ', node.position())
|
c.error('checker: too many expr levels: $c.expr_level ', node.position())
|
||||||
return table.void_type
|
return table.void_type
|
||||||
}
|
}
|
||||||
|
|
||||||
match mut node {
|
match mut node {
|
||||||
ast.AnonFn {
|
ast.AnonFn {
|
||||||
keep_fn := c.cur_fn
|
keep_fn := c.cur_fn
|
||||||
|
@ -1851,7 +1851,12 @@ pub fn (mut c Checker) expr(node ast.Expr) table.Type {
|
||||||
ast.ComptimeCall {
|
ast.ComptimeCall {
|
||||||
it.sym = c.table.get_type_symbol(c.unwrap_generic(c.expr(it.left)))
|
it.sym = c.table.get_type_symbol(c.unwrap_generic(c.expr(it.left)))
|
||||||
if it.is_vweb {
|
if it.is_vweb {
|
||||||
mut c2 := new_checker(c.table, c.pref)
|
x := *c.pref
|
||||||
|
xx := {
|
||||||
|
x |
|
||||||
|
is_vweb: true
|
||||||
|
} // TODO assoc parser bug
|
||||||
|
mut c2 := new_checker(c.table, xx)
|
||||||
c2.check(it.vweb_tmpl)
|
c2.check(it.vweb_tmpl)
|
||||||
c.warnings << c2.warnings
|
c.warnings << c2.warnings
|
||||||
c.errors << c2.errors
|
c.errors << c2.errors
|
||||||
|
@ -1953,7 +1958,8 @@ pub fn (mut c Checker) expr(node ast.Expr) table.Type {
|
||||||
if !c.check_types(ltype, table.bool_type) {
|
if !c.check_types(ltype, table.bool_type) {
|
||||||
ltype_sym := c.table.get_type_symbol(ltype)
|
ltype_sym := c.table.get_type_symbol(ltype)
|
||||||
lname := if it.is_likely { '_likely_' } else { '_unlikely_' }
|
lname := if it.is_likely { '_likely_' } else { '_unlikely_' }
|
||||||
c.error('`${lname}()` expects a boolean expression, instead it got `${ltype_sym.name}`', it.pos)
|
c.error('`${lname}()` expects a boolean expression, instead it got `${ltype_sym.name}`',
|
||||||
|
it.pos)
|
||||||
}
|
}
|
||||||
return table.bool_type
|
return table.bool_type
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn (g &Gen) comptime_call(node ast.ComptimeCall) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.writeln('vweb__Context_html(&app->vweb, tmpl_res_$g.fn_decl.name)')
|
g.writeln('vweb__Context_html(&app->vweb, _tmpl_res_$g.fn_decl.name)')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
g.writeln('// $' + 'method call. sym="$node.sym.name"')
|
g.writeln('// $' + 'method call. sym="$node.sym.name"')
|
||||||
|
|
|
@ -112,6 +112,7 @@ pub mut:
|
||||||
use_color ColorOutput // whether the warnings/errors should use ANSI color escapes.
|
use_color ColorOutput // whether the warnings/errors should use ANSI color escapes.
|
||||||
is_parallel bool
|
is_parallel bool
|
||||||
error_limit int
|
error_limit int
|
||||||
|
is_vweb bool // skip _ var warning in templates
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_args(args []string) (&Preferences, string) {
|
pub fn parse_args(args []string) (&Preferences, string) {
|
||||||
|
|
|
@ -113,7 +113,7 @@ pub fn compile_template(content, fn_name string) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.writeln(str_end)
|
s.writeln(str_end)
|
||||||
s.writeln('tmpl_res_$fn_name := sb.str() ')
|
s.writeln('_tmpl_res_$fn_name := sb.str() ')
|
||||||
s.writeln('}')
|
s.writeln('}')
|
||||||
s.writeln('// === end of vweb html template ===')
|
s.writeln('// === end of vweb html template ===')
|
||||||
return s.str()
|
return s.str()
|
||||||
|
|
Loading…
Reference in New Issue