parser: update check for non mut types in fn
parent
962bbf1c60
commit
d286f67220
|
@ -1,5 +1,5 @@
|
||||||
vlib/v/checker/tests/function_arg_mutable_err.v:1:18: error: mutable arguments are only allowed for arrays, maps, and structs
|
vlib/v/checker/tests/function_arg_mutable_err.v:1:18: error: mutable arguments are only allowed for arrays, maps, and structs
|
||||||
return values instead: `fn foo(n mut int) {` => `fn foo(n int) int {`
|
return values instead: `fn foo(mut n int) {` => `fn foo(n int) int {`
|
||||||
1 | fn mod_ptr(mut a int) {
|
1 | fn mod_ptr(mut a int) {
|
||||||
| ~~~
|
| ~~~
|
||||||
2 | a = 77
|
2 | a = 77
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
vlib/v/checker/tests/mut_int.v:1:14: error: mutable arguments are only allowed for arrays, maps, and structs
|
vlib/v/checker/tests/mut_int.v:1:14: error: mutable arguments are only allowed for arrays, maps, and structs
|
||||||
return values instead: `fn foo(n mut int) {` => `fn foo(n int) int {`
|
return values instead: `fn foo(mut n int) {` => `fn foo(n int) int {`
|
||||||
1 | fn foo(mut x int) {
|
1 | fn foo(mut x int) {
|
||||||
| ~~~
|
| ~~~
|
||||||
2 | }
|
2 | }
|
||||||
|
|
|
@ -458,7 +458,7 @@ fn (mut p Parser) check_fn_mutable_arguments(typ table.Type, pos token.Position)
|
||||||
sym := p.table.get_type_symbol(typ)
|
sym := p.table.get_type_symbol(typ)
|
||||||
if sym.kind !in [.array, .struct_, .map, .placeholder] && !typ.is_ptr() {
|
if sym.kind !in [.array, .struct_, .map, .placeholder] && !typ.is_ptr() {
|
||||||
p.error_with_pos('mutable arguments are only allowed for arrays, maps, and structs\n' +
|
p.error_with_pos('mutable arguments are only allowed for arrays, maps, and structs\n' +
|
||||||
'return values instead: `fn foo(n mut int) {` => `fn foo(n int) int {`', pos)
|
'return values instead: `fn foo(mut n $sym.name) {` => `fn foo(n $sym.name) $sym.name {`', pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue