parser: check fn args in declarations too with `-Wimpure-v`

`v -Wimpure-v examples/2048/` now passes cleanly.
pull/12379/head
Delyan Angelov 2021-11-03 16:20:19 +02:00
parent 4bafc5042b
commit c4e282a0c8
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 13 additions and 1 deletions

View File

@ -122,7 +122,7 @@ pub fn (mut ctx Context) refresh_ui() {
ctx.ticks = 0
}
fn gg_event_fn(ce &C.sapp_event, user_data voidptr) {
fn gg_event_fn(ce voidptr, user_data voidptr) {
// e := unsafe { &sapp.Event(ce) }
mut e := unsafe { &Event(ce) }
mut g := unsafe { &Context(user_data) }

View File

@ -591,6 +591,10 @@ fn (mut p Parser) fn_receiver(mut params []ast.Param, mut rec ReceiverParsingInf
}
}
if rec.language != .v {
p.check_for_impure_v(rec.language, rec.type_pos)
}
params << ast.Param{
pos: rec_start_pos
name: rec.name
@ -833,6 +837,10 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) {
}
p.next()
}
alanguage := p.table.get_type_symbol(arg_type).language
if alanguage != .v {
p.check_for_impure_v(alanguage, pos)
}
args << ast.Param{
pos: pos
name: ''
@ -918,6 +926,10 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) {
typ = ast.new_type(p.table.find_or_register_array(typ)).derive(typ).set_flag(.variadic)
}
for i, arg_name in arg_names {
alanguage := p.table.get_type_symbol(typ).language
if alanguage != .v {
p.check_for_impure_v(alanguage, type_pos[i])
}
args << ast.Param{
pos: arg_pos[i]
name: arg_name