diff --git a/compiler/fn.v b/compiler/fn.v index 861328328c..542c3791c5 100644 --- a/compiler/fn.v +++ b/compiler/fn.v @@ -144,7 +144,7 @@ fn (p mut Parser) fn_decl() { // Don't allow modifying types from a different module if !p.first_run() && !p.builtin_pkg && T.mod != p.mod { println('T.mod=$T.mod') - println('pkg=$p.mod') + println('p.mod=$p.mod') p.error('cannot define new methods on non-local type `$receiver_typ`') } // (a *Foo) instead of (a mut Foo) is a common mistake @@ -533,7 +533,7 @@ fn (p mut Parser) fn_call(f Fn, method_ph int, receiver_var, receiver_type strin receiver := f.args.first() if receiver.is_mut && !p.expr_var.is_mut { println('$method_call recv=$receiver.name recv_mut=$receiver.is_mut') - p.error('`$p.expr_var.name` is imkey_mut') + p.error('`$p.expr_var.name` is immutable') } // if receiver is key_mut or a ref (&), generate & for the first arg if receiver.ref || (receiver.is_mut && !receiver_type.contains('*')) { diff --git a/compiler/parser.v b/compiler/parser.v index e1e15135a3..9149eecea3 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -391,7 +391,7 @@ fn (p mut Parser) type_decl() { // so specify "struct" _struct := if !parent.contains('[') && !parent.starts_with('fn ') && !p.table.known_type(parent){'struct'} else { ''} p.gen_typedef('typedef $_struct $nt_pair; // type alias name="$name" parent="$parent"') - p.table.register_type_with_parent(name, parent) + p.register_type_with_parent(name, parent) } fn (p mut Parser) interface_method(field_name, receiver string) &Fn { @@ -1066,7 +1066,7 @@ fn (p mut Parser) assign_statement(v Var, ph int, is_map bool) { p.log('assign_statement() name=$v.name tok=') tok := p.tok if !v.is_mut && !v.is_arg && !p.pref.translated && !v.is_global{ - p.error('`$v.name` is imkey_mut') + p.error('`$v.name` is immutable') } is_str := v.typ == 'string' switch tok { @@ -1488,7 +1488,7 @@ fn (p mut Parser) var_expr(v Var) string { // a++ and a-- if p.tok == .inc || p.tok == .dec { if !v.is_mut && !v.is_arg && !p.pref.translated { - p.error('`$v.name` is imkey_mut') + p.error('`$v.name` is immutable') } if typ != 'int' { if !p.pref.translated && !is_number_type(typ) { @@ -1567,7 +1567,7 @@ fn (p mut Parser) dot(str_typ string, method_ph int) string { modifying := next.is_assign() || next == .inc || next == .dec is_vi := p.fileis('vi') if !p.builtin_pkg && !p.pref.translated && modifying && !field.is_mut && !is_vi { - p.error('cannot modify imkey_mut field `$field_name` (type `$typ.name`)') + p.error('cannot modify immutable field `$field_name` (type `$typ.name`)') } if !p.builtin_pkg && p.mod != typ.mod { } @@ -1582,7 +1582,7 @@ fn (p mut Parser) dot(str_typ string, method_ph int) string { // Don't allow `str.len = 0` if field.access_mod == .public && !p.builtin_pkg && p.mod != typ.mod { if !field.is_mut && !p.pref.translated && modifying { - p.error('cannot modify public imkey_mut field `$field_name` (type `$typ.name`)') + p.error('cannot modify public immutable field `$field_name` (type `$typ.name`)') } } p.gen(dot + field_name) @@ -1725,7 +1725,7 @@ fn (p mut Parser) index_expr(typ string, fn_ph int) string { p.tok == .or_assign || p.tok == .and_assign || p.tok == .righ_shift_assign || p.tok == .left_shift_assign { if is_indexer && is_str && !p.builtin_pkg { - p.error('strings are imkey_mut') + p.error('strings are immutable') } assign_pos := p.cgen.cur_line.len p.assigned_type = typ @@ -1822,7 +1822,7 @@ fn (p mut Parser) expression() string { p.gen(', (') // Imkey_mut? Can we push? if !p.expr_var.is_mut && !p.pref.translated { - p.error('`$p.expr_var.name` is imkey_mut (can\'t <<)') + p.error('`$p.expr_var.name` is immutable (can\'t <<)') } expr_type := p.expression() // Two arrays of the same type? diff --git a/compiler/table.v b/compiler/table.v index 1b7e167aa4..dbca9145e4 100644 --- a/compiler/table.v +++ b/compiler/table.v @@ -258,18 +258,17 @@ if parent == 'array' { pkg = 'builtin' } */ - datyp := Type { + t.types << Type { name: typ parent: parent + //mod: mod } - t.types << datyp } fn (t mut Table) register_type2(typ Type) { if typ.name.len == 0 { return } - // println('register type2 $typ.name') for typ2 in t.types { if typ2.name == typ.name { return