tests: more interface tests; checker: handle zero selectorexpr type error
parent
c500044bae
commit
51d0ce0222
|
@ -481,6 +481,10 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) {
|
||||||
}
|
}
|
||||||
ast.SelectorExpr {
|
ast.SelectorExpr {
|
||||||
// retrieve table.Field
|
// 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)
|
typ_sym := c.table.get_type_symbol(it.expr_type)
|
||||||
match typ_sym.kind {
|
match typ_sym.kind {
|
||||||
.struct_ {
|
.struct_ {
|
||||||
|
|
|
@ -56,22 +56,9 @@ fn test_perform_speak() {
|
||||||
|
|
||||||
fn perform_speakers(speakers []Speaker) {}
|
fn perform_speakers(speakers []Speaker) {}
|
||||||
|
|
||||||
/*
|
|
||||||
interface Speak2er {
|
|
||||||
name ()string
|
|
||||||
speak()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct Foo {
|
|
||||||
speaker Speaker
|
|
||||||
speakers []Speaker
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface Register {
|
interface Register {
|
||||||
register()}
|
register()
|
||||||
|
}
|
||||||
|
|
||||||
struct RegTest {
|
struct RegTest {
|
||||||
a int
|
a int
|
||||||
|
@ -82,12 +69,19 @@ fn (f RegTest) register() {}
|
||||||
fn handle_reg(r Register) {}
|
fn handle_reg(r Register) {}
|
||||||
|
|
||||||
fn test_register() {
|
fn test_register() {
|
||||||
if true {
|
|
||||||
// QTODO
|
|
||||||
return
|
|
||||||
}
|
|
||||||
f := RegTest{}
|
f := RegTest{}
|
||||||
f.register()
|
f.register()
|
||||||
handle_reg(f)
|
handle_reg(f)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
interface Speaker2 {
|
||||||
|
name() string
|
||||||
|
speak()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct Foo {
|
||||||
|
//speaker Speaker
|
||||||
|
//speakers []Speaker
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue