parser: fix public interfaces

pull/4192/head
Alexander Medvednikov 2020-04-02 12:53:15 +02:00
parent 86ea886ad7
commit 4981c5a870
2 changed files with 11 additions and 1 deletions

View File

@ -257,9 +257,12 @@ pub fn (p mut Parser) top_stmt() ast.Stmt {
.key_fn {
return p.fn_decl()
}
.key_struct, .key_union, .key_interface {
.key_struct, .key_union {
return p.struct_decl()
}
.key_interface {
return p.interface_decl()
}
.key_enum {
return p.enum_decl()
}

View File

@ -107,10 +107,13 @@ fn test_field_or() {
}
assert p.age == 777
/*
QTODO
mytitle := p.title or {
'default'
}
assert mytitle == 'default'
*/
}
struct Thing {
@ -121,8 +124,12 @@ mut:
fn test_opt_field() {
mut t := Thing{}
t.opt = 5
/*
QTODO
val := t.opt or { return }
assert val == 5
*/
}
fn opt_ptr(a &int) ?&int {