mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
parser: a small immutable field fix
This commit is contained in:
parent
343dced36d
commit
ae2af4c36d
3 changed files with 14 additions and 6 deletions
|
@ -2179,9 +2179,8 @@ fn (p mut Parser) dot(str_typ_ string, method_ph int) string {
|
|||
next := p.peek()
|
||||
modifying := next.is_assign() || next == .inc || next == .dec ||
|
||||
(field.typ.starts_with('array_') && next == .left_shift)
|
||||
is_vi := p.fileis('vid')
|
||||
if !p.builtin_mod && !p.pref.translated && modifying && !is_vi
|
||||
&& p.has_immutable_field {
|
||||
if !p.builtin_mod && !p.pref.translated && modifying &&
|
||||
p.has_immutable_field {
|
||||
f := p.first_immutable_field
|
||||
p.error_with_token_index('cannot modify immutable field `$f.name` (type `$f.parent_fn`)\n' +
|
||||
'declare the field with `mut:`
|
||||
|
@ -2190,8 +2189,6 @@ struct $f.parent_fn {
|
|||
$f.name $f.typ
|
||||
}
|
||||
', fname_tidx)
|
||||
}
|
||||
if !p.builtin_mod && p.mod != typ.mod {
|
||||
}
|
||||
// Don't allow `arr.data`
|
||||
if field.access_mod == .private && !p.builtin_mod && !p.pref.translated && p.mod != typ.mod {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue