Skip to content

unexpect panic: promoted embedded method missing in itab for interface assertions #1559

@luoliwoshang

Description

@luoliwoshang

cl/_testgo/interface

package main

import (
	"github.com/goplus/llgo/cl/_testdata/foo"
)

type Game1 struct {
	*foo.Game
}

type Game2 struct {
}

func (p *Game2) initGame() {
}

func main() {
	var g1 any = &Game1{&foo.Game{}}
	var g2 any = &Game2{}
	v1, ok := g1.(foo.Gamer)
	println("OK", v1, ok)
	if ok {
		v1.Load()
	}
	v2, ok := g2.(foo.Gamer)
	println("FAIL", v2, ok)
}

expect

cl/_testgo/interface on  expect-output-tests [$!?] via 🐹 v1.24.10 
❯ go run in.go
OK (0x12b94ffc8,0x14000104000) true
load
FAIL (0x0,0x1400005c727) false

got

cl/_testgo/interface on  expect-output-tests [$!?] via 🐹 v1.24.10 
❯ llgo run in.go
WARNING: Using LLGO root for devel: /Users/zhangzhiyang/Documents/Code/goplus/llgo
WARNING: Using LLGO root for devel: /Users/zhangzhiyang/Documents/Code/goplus/llgo
WARNING: Using LLGO root for devel: /Users/zhangzhiyang/Documents/Code/goplus/llgo
OK (0x102c83f90,0x102c81fc0) true
panic: runtime error: invalid memory address or nil pointer dereference

[0x02A4EAF8 github.com/goplus/llgo/runtime/internal/runtime.init#4$1+0x38, SP = 0x48]
[0x8AB5C624 _sigtramp+0x9, SP = 0x38]
[0x02A50A8C command-line-arguments.main+0x1b, SP = 0x70]
exit status 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions