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

.key_type

This commit is contained in:
Alexander Medvednikov
2019-07-16 12:17:17 +02:00
parent 961ffb1868
commit 0a4a9a35c3
2 changed files with 11 additions and 7 deletions

View File

@@ -189,7 +189,7 @@ fn (p mut Parser) parse() {
}
case Token.func:
p.fn_decl()
case Token.typ:
case Token.key_type:
p.type_decl()
case Token.lsbr:
// `[` can only mean an [attribute] before a function
@@ -401,7 +401,7 @@ fn (p mut Parser) const_decl() {
// `type myint int`
// `type onclickfn fn(voidptr) int`
fn (p mut Parser) type_decl() {
p.check(.typ)
p.check(.key_type)
name := p.check_name()
parent := p.get_type()
nt_pair := p.table.cgen_name_type_pair(name, parent)
@@ -642,7 +642,12 @@ fn (p mut Parser) enum_decl(_enum_name string) {
// check_name checks for a name token and returns its literal
fn (p mut Parser) check_name() string {
if p.tok == .key_type {
p.check(.key_type)
return 'type'
}
name := p.lit
p.check(.name)
return name
}
@@ -1569,9 +1574,8 @@ fn (p mut Parser) dot(str_typ string, method_ph int) string {
has_field := p.table.type_has_field(typ, field_name)
has_method := p.table.type_has_method(typ, field_name)
if !typ.is_c && !has_field && !has_method && !p.first_run() {
// println(typ.str())
if typ.name.starts_with('Option_') {
opt_type := typ.name.substr(7, typ.name.len)
opt_type := typ.name.right(7)
p.error('unhandled option type: $opt_type?')
}
println('error in dot():')