tests: more interface tests; checker: handle zero selectorexpr type error

pull/4645/head
Alexander Medvednikov 2020-04-29 12:46:06 +02:00
parent c500044bae
commit 51d0ce0222
2 changed files with 18 additions and 20 deletions

View File

@ -481,6 +481,10 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) {
}
ast.SelectorExpr {
// retrieve table.Field
if it.expr_type == 0 {
c.error('0 type in SelectorExpr', expr.position())
return
}
typ_sym := c.table.get_type_symbol(it.expr_type)
match typ_sym.kind {
.struct_ {

View File

@ -56,22 +56,9 @@ fn test_perform_speak() {
fn perform_speakers(speakers []Speaker) {}
/*
interface Speak2er {
name ()string
speak()
}
struct Foo {
speaker Speaker
speakers []Speaker
}
interface Register {
register()}
register()
}
struct RegTest {
a int
@ -82,12 +69,19 @@ fn (f RegTest) register() {}
fn handle_reg(r Register) {}
fn test_register() {
if true {
// QTODO
return
}
f := RegTest{}
f.register()
handle_reg(f)
}
*/
interface Speaker2 {
name() string
speak()
}
struct Foo {
//speaker Speaker
//speakers []Speaker
}