From c4e282a0c8e1701273e24a39739eb57a8c9a83de Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 3 Nov 2021 16:20:19 +0200 Subject: [PATCH] parser: check fn args in declarations too with `-Wimpure-v` `v -Wimpure-v examples/2048/` now passes cleanly. --- vlib/gg/gg.v | 2 +- vlib/v/parser/fn.v | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/vlib/gg/gg.v b/vlib/gg/gg.v index 233d3a7e2d..6ff3c04a17 100644 --- a/vlib/gg/gg.v +++ b/vlib/gg/gg.v @@ -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) } diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index bc9c6e6126..a6b1d9d1a5 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -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