checker: remove vweb unused vars (#8180)
parent
f7c251f8f3
commit
4045ec1ca8
|
@ -73,6 +73,7 @@ mut:
|
||||||
loop_label string // set when inside a labelled for loop
|
loop_label string // set when inside a labelled for loop
|
||||||
timers &util.Timers = util.new_timers(false)
|
timers &util.Timers = util.new_timers(false)
|
||||||
comptime_fields_type map[string]table.Type
|
comptime_fields_type map[string]table.Type
|
||||||
|
fn_scope &ast.Scope = voidptr(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_checker(table &table.Table, pref &pref.Preferences) Checker {
|
pub fn new_checker(table &table.Table, pref &pref.Preferences) Checker {
|
||||||
|
@ -3584,6 +3585,19 @@ fn (mut c Checker) comptime_call(mut node ast.ComptimeCall) table.Type {
|
||||||
}
|
}
|
||||||
mut c2 := new_checker(c.table, pref2)
|
mut c2 := new_checker(c.table, pref2)
|
||||||
c2.check(node.vweb_tmpl)
|
c2.check(node.vweb_tmpl)
|
||||||
|
mut i := 0 // tmp counter var for skipping first three tmpl vars
|
||||||
|
for k, _ in c2.file.scope.children[0].objects {
|
||||||
|
if i < 4 {
|
||||||
|
// Skip first three because they are tmpl vars see vlib/vweb/tmpl/tmpl.v
|
||||||
|
i++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if k in c.fn_scope.objects && c.fn_scope.objects[k] is ast.Var {
|
||||||
|
mut vsc := c.fn_scope.objects[k] as ast.Var
|
||||||
|
vsc.is_used = true
|
||||||
|
c.fn_scope.objects[k] = vsc
|
||||||
|
}
|
||||||
|
}
|
||||||
c.warnings << c2.warnings
|
c.warnings << c2.warnings
|
||||||
c.errors << c2.errors
|
c.errors << c2.errors
|
||||||
c.nr_warnings += c2.nr_warnings
|
c.nr_warnings += c2.nr_warnings
|
||||||
|
@ -5319,6 +5333,7 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c.fn_scope = node.scope
|
||||||
c.stmts(node.stmts)
|
c.stmts(node.stmts)
|
||||||
returns := c.returns || has_top_return(node.stmts)
|
returns := c.returns || has_top_return(node.stmts)
|
||||||
if node.language == .v && !node.no_body && node.return_type != table.void_type && !returns &&
|
if node.language == .v && !node.no_body && node.return_type != table.void_type && !returns &&
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
@test
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import vweb
|
||||||
|
|
||||||
|
struct App {
|
||||||
|
vweb.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (mut app App) index() vweb.Result {
|
||||||
|
test := 'test'
|
||||||
|
return $vweb.html()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
mut app := App{}
|
||||||
|
vweb.run_app<App>(mut app, 8181)
|
||||||
|
}
|
|
@ -11,6 +11,10 @@ const skip_files = [
|
||||||
'vlib/v/checker/tests/custom_comptime_define_if_flag.vv',
|
'vlib/v/checker/tests/custom_comptime_define_if_flag.vv',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const skip_on_ubuntu_musl = [
|
||||||
|
'vlib/v/checker/tests/vweb_tmpl_used_var.vv',
|
||||||
|
]
|
||||||
|
|
||||||
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
|
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
|
||||||
|
|
||||||
const should_autofix = os.getenv('VAUTOFIX') != ''
|
const should_autofix = os.getenv('VAUTOFIX') != ''
|
||||||
|
@ -89,6 +93,9 @@ fn (mut tasks []TaskDescription) run() {
|
||||||
mut work := sync.new_channel<TaskDescription>(tasks.len)
|
mut work := sync.new_channel<TaskDescription>(tasks.len)
|
||||||
mut results := sync.new_channel<TaskDescription>(tasks.len)
|
mut results := sync.new_channel<TaskDescription>(tasks.len)
|
||||||
mut m_skip_files := skip_files.clone()
|
mut m_skip_files := skip_files.clone()
|
||||||
|
if os.getenv('V_CI_UBUNTU_MUSL').len > 0 {
|
||||||
|
m_skip_files << skip_on_ubuntu_musl
|
||||||
|
}
|
||||||
$if noskip ? {
|
$if noskip ? {
|
||||||
m_skip_files = []
|
m_skip_files = []
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,9 +109,10 @@ fn (mut p Parser) comp_call() ast.ComptimeCall {
|
||||||
fn_path := p.cur_fn_name.split('_')
|
fn_path := p.cur_fn_name.split('_')
|
||||||
tmpl_path := if is_html { '${fn_path.last()}.html' } else { s }
|
tmpl_path := if is_html { '${fn_path.last()}.html' } else { s }
|
||||||
// Looking next to the vweb program
|
// Looking next to the vweb program
|
||||||
dir := os.dir(p.scanner.file_path)
|
dir := os.dir(p.scanner.file_path.replace('/', os.path_separator))
|
||||||
mut path := os.join_path(dir, fn_path.join('/'))
|
mut path := os.join_path(dir, fn_path.join(os.path_separator))
|
||||||
path += '.html'
|
path += '.html'
|
||||||
|
path = os.real_path(path)
|
||||||
if !is_html {
|
if !is_html {
|
||||||
path = tmpl_path
|
path = tmpl_path
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue