neugram / ng

scripting language integrated with Go
https://neugram.io
BSD 2-Clause "Simplified" License
916 stars 43 forks source link

ng: embedded fields of Go exported types are not wrapped correctly #178

Closed sbinet closed 6 years ago

sbinet commented 6 years ago

the following fails in ng:

$> cat t-hplot.ng
import "go-hep.org/x/hep/hplot"
p := hplot.New()
p.Title.Text = "hello"
printf("title=%q\n", p.Plot.Title.Text)

$> ng ./t-hplot.ng 

ng: typecheck: p.Title undefined (type struct {
    Plot  *Plot
    Style Style
} has no field or method Title)

title=""

hplot.Plot embeds gonum/v1/plot.Plot:

type Plot struct {
    *plot.Plot
    Style Style
}

but we still need to explicitly mention p.Plot.Title to access that field (although this works for embedded types defined directly from ng.)