oxfeeefeee/goscript

member resolution fails with embedded structs

mothfuzz opened this issue · 1 comments

Hello! Wonderful project. I was playing around with embedded structs as they're a golang feature I quite like, and I found that fields and methods aren't promoted in goscript like they are in golang proper:

package main

import (
	"fmt"
)

type Base struct {
	name string
}
func (b Base) PrintField() {
	fmt.Println(b.name)
}

type Container struct {
	Base
}

func main() {
	t := Container{Base{"go"}}
        //t.PrintField() //error in goscript, but works in golang
	t.Base.PrintField() //have to use this instead
}

I'm not sure if this is an issue with the go specs, or simply this implementation. I'm not even sure if implementing field promotion is on the table. But I felt it was worth bringing up anyway.
The error specifically when trying to run this script is:
thread 'main' panicked at 'no entry found for key', ...\vm\src\metadata.rs:493:9
so it seems to be an error with field name resolution.

It surely is a bug, will fix. Thanks for reporting.