Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
getVStruct: type not found
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jul 23, 2022
1 parent 8c6a367 commit d941457
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cl/blockctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ func (p *blockCtx) buildVStruct(struc *types.Struct, vfs gox.VFields) *types.Str
}

func (p *blockCtx) getVStruct(typ *types.Named) *types.Struct {
t := typ.Underlying().(*types.Struct)
t, ok := typ.Underlying().(*types.Struct)
if !ok {
log.Panicln(typ.Obj().Name(), "not found")
}
if vfs, ok := p.pkg.VFields(typ); ok {
t = p.buildVStruct(t, vfs)
}
Expand Down
17 changes: 17 additions & 0 deletions cl/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ func testPanic(t *testing.T, panicMsg string, doPanic func()) {

// -----------------------------------------------------------------------------

func TestGetVStruct(t *testing.T) {
defer func() {
if e := recover(); e != nil {
if emsg, ok := e.(string); ok {
if emsg == "foo not found\n" {
return
}
}
t.Fatal("TestGetVStruct failed:", e)
}
t.Fatal("TestGetVStruct: no error?")
}()
var ctx blockCtx
typ := types.NewNamed(types.NewTypeName(0, nil, "foo", nil), nil, nil)
ctx.getVStruct(typ)
}

func TestFuncAndDecl(t *testing.T) {
testFunc(t, "testKeyword", `
void test(int var) {
Expand Down

0 comments on commit d941457

Please sign in to comment.