diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 147abe135351b7..451609281f4365 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -22,7 +22,7 @@ const type_level_cutoff_limit = 40 // it is very rarely deeper than 4 const iface_level_cutoff_limit = 100 const generic_fn_cutoff_limit_per_fn = 10_000 // how many times post_process_generic_fns, can visit the same function before bailing out -const generic_fn_postprocess_iterations_cutoff_limit = 1000_000 +const generic_fn_postprocess_iterations_cutoff_limit = 1_000_000 // array_builtin_methods contains a list of all methods on array, that return other typed arrays, // i.e. that act as *pseudogeneric* methods, that need compiler support, so that the types of the results @@ -4707,12 +4707,12 @@ fn (mut c Checker) index_expr(mut node ast.IndexExpr) ast.Type { && typ_sym.kind == .map && node.or_expr.stmts.len == 0 { elem_type := c.table.value_type(typ) if elem_type.is_any_kind_of_pointer() { - c.note('accessing a pointer map value requires an `or {}` block outside `unsafe`', + c.warn('accessing a pointer map value requires an `or {}` block outside `unsafe`', node.pos) } mut checked_types := []ast.Type{} if c.is_contains_any_kind_of_pointer(elem_type, mut checked_types) { - c.note('accessing map value that contain pointers requires an `or {}` block outside `unsafe`', + c.warn('accessing map value that contain pointers requires an `or {}` block outside `unsafe`', node.pos) } } @@ -4738,7 +4738,7 @@ fn (mut c Checker) index_expr(mut node ast.IndexExpr) ast.Type { } else if is_mut_struct { c.error('type `mut ${typ_sym.name}` does not support slicing', node.pos) } else if !c.inside_unsafe && !is_ok && !c.pref.translated && !c.file.is_translated { - c.warn('pointer indexing is only allowed in `unsafe` blocks', node.pos) + c.error('pointer indexing is only allowed in `unsafe` blocks', node.pos) } } if mut node.index is ast.RangeExpr { // [1..2] diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 5734f48bfb7db2..30159bc262f9b8 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -15,13 +15,14 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) { } // record the vweb route methods (public non-generic methods): if node.generic_names.len > 0 && node.is_pub { - typ_vweb_result := c.table.find_type_idx('vweb.Result') + typ_vweb_result := c.table.find_type_idx('veb.Result') if node.return_type == typ_vweb_result { rec_sym := c.table.sym(node.receiver.typ) if rec_sym.kind == .struct_ { if _ := c.table.find_field_with_embeds(rec_sym, 'Context') { - // there is no point in the message here, for methods that are not public; since they will not be available as routes anyway - c.note('generic method routes of vweb will be skipped', node.pos) + // there is no point in the message here, for methods + // that are not public; since they will not be available as routes anyway + c.note('generic method routes of veb will be skipped', node.pos) } } } diff --git a/vlib/v/checker/tests/index_sumtype_interface_struct_params_err.out b/vlib/v/checker/tests/index_sumtype_interface_struct_params_err.out index 10cd637b129d4c..b96d684a4d9dad 100644 --- a/vlib/v/checker/tests/index_sumtype_interface_struct_params_err.out +++ b/vlib/v/checker/tests/index_sumtype_interface_struct_params_err.out @@ -1,12 +1,5 @@ -vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:12:9: warning: pointer indexing is only allowed in `unsafe` blocks - 10 | - 11 | _ = st1[0] - 12 | _ = st2[0] - | ~~~ - 13 | _ = st3[0] - 14 | } vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:8:9: error: type `Foo` does not support indexing - 6 | + 6 | 7 | fn sum_type_or_interface_as_parameters(mut foo Foo, mut bar Bar, mut st1 Struct, st2 &Struct, st3 Struct) { 8 | _ = foo[0] | ~~~ @@ -17,15 +10,22 @@ vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:9:9: error: ty 8 | _ = foo[0] 9 | _ = bar[0] | ~~~ - 10 | + 10 | 11 | _ = st1[0] vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:11:9: error: type `mut Struct` does not support slicing 9 | _ = bar[0] - 10 | + 10 | 11 | _ = st1[0] | ~~~ 12 | _ = st2[0] 13 | _ = st3[0] +vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:12:9: error: pointer indexing is only allowed in `unsafe` blocks + 10 | + 11 | _ = st1[0] + 12 | _ = st2[0] + | ~~~ + 13 | _ = st3[0] + 14 | } vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:13:9: error: type `Struct` does not support indexing 11 | _ = st1[0] 12 | _ = st2[0] diff --git a/vlib/v/checker/tests/map_index_reference_value.out b/vlib/v/checker/tests/map_index_reference_value.out index b2aaf787b330cf..5ae73279bd2887 100644 --- a/vlib/v/checker/tests/map_index_reference_value.out +++ b/vlib/v/checker/tests/map_index_reference_value.out @@ -1,26 +1,26 @@ -vlib/v/checker/tests/map_index_reference_value.vv:11:3: notice: accessing a pointer map value requires an `or {}` block outside `unsafe` +vlib/v/checker/tests/map_index_reference_value.vv:11:3: warning: accessing a pointer map value requires an `or {}` block outside `unsafe` 9 | fn main() { 10 | mut m := map[string]&Foo{} 11 | m['bar'].bar = 'bar' | ~~~~~~~ 12 | // m['bar'] << 'baz' // etc 13 | -vlib/v/checker/tests/map_index_reference_value.vv:11:3: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe` +vlib/v/checker/tests/map_index_reference_value.vv:11:3: warning: accessing map value that contain pointers requires an `or {}` block outside `unsafe` 9 | fn main() { 10 | mut m := map[string]&Foo{} 11 | m['bar'].bar = 'bar' | ~~~~~~~ 12 | // m['bar'] << 'baz' // etc 13 | -vlib/v/checker/tests/map_index_reference_value.vv:15:8: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe` - 13 | +vlib/v/checker/tests/map_index_reference_value.vv:15:8: warning: accessing map value that contain pointers requires an `or {}` block outside `unsafe` + 13 | 14 | mut m2 := map[string]Bar{} 15 | _ = m2['key'] | ~~~~~~~ - 16 | + 16 | 17 | mut m3 := map[string][]Bar{} -vlib/v/checker/tests/map_index_reference_value.vv:18:8: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe` - 16 | +vlib/v/checker/tests/map_index_reference_value.vv:18:8: warning: accessing map value that contain pointers requires an `or {}` block outside `unsafe` + 16 | 17 | mut m3 := map[string][]Bar{} 18 | _ = m3['key'] | ~~~~~~~ diff --git a/vlib/v/checker/tests/unsafe_required.out b/vlib/v/checker/tests/unsafe_required.out index 168715f7930bb2..e98fd4044522df 100644 --- a/vlib/v/checker/tests/unsafe_required.out +++ b/vlib/v/checker/tests/unsafe_required.out @@ -5,14 +5,14 @@ vlib/v/checker/tests/unsafe_required.vv:8:4: warning: method `S1.f` must be call | ~~~ 9 | } 10 | -vlib/v/checker/tests/unsafe_required.vv:16:7: warning: pointer indexing is only allowed in `unsafe` blocks +vlib/v/checker/tests/unsafe_required.vv:16:7: error: pointer indexing is only allowed in `unsafe` blocks 14 | _ = b[0] // OK 15 | c := &b 16 | _ = c[0] | ~~~ 17 | 18 | v := 4 -vlib/v/checker/tests/unsafe_required.vv:20:7: warning: pointer indexing is only allowed in `unsafe` blocks +vlib/v/checker/tests/unsafe_required.vv:20:7: error: pointer indexing is only allowed in `unsafe` blocks 18 | v := 4 19 | p := &v 20 | _ = p[0] diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 3e4a146f5f31ea..8b91ded8981cd9 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1881,7 +1881,7 @@ fn (mut p Parser) attributes() { start_pos := p.tok.pos() mut is_at := false if p.tok.kind == .lsbr { - p.note('`[attr]` has been deprecated, use `@[attr]` instead') + p.warn('`[attr]` has been deprecated, use `@[attr]` instead') // [attr] p.check(.lsbr) } else if p.tok.kind == .at {