1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

interface fix

This commit is contained in:
Alexander Medvednikov
2020-01-09 01:39:47 +01:00
parent c1cc203c17
commit 29564ed63d
7 changed files with 61 additions and 53 deletions

View File

@@ -2112,6 +2112,9 @@ fn (p mut Parser) dot(str_typ_ string, method_ph int) string {
// Is the next token `=`, `+=` etc? (Are we modifying the field?)
next := p.peek()
modifying := next.is_assign() || next == .inc || next == .dec || (field.typ.starts_with('array_') && next == .left_shift)
if modifying {
p.expected_type = field.typ
}
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:`
@@ -2705,7 +2708,7 @@ fn (p mut Parser) array_init() string {
// vals.len == 0 {
if exp_array {
type_expected := p.expected_type[6..].replace('ptr_', '&')
p.error('no need to specify the full array type here, use `[]` instead of `[]$type_expected`')
p.warn('no need to specify the full array type here, use `[]` instead of `[]$type_expected`')
}
typ = p.get_type()
}