matthewmueller / joy

A delightful Go to Javascript compiler (ON HOLD)
https://mat.tm/joy
GNU General Public License v3.0
1.32k stars 35 forks source link

Fix non-struct types with methods on them #83

Open matthewmueller opened 6 years ago

matthewmueller commented 6 years ago

Right now this will panic:

package main

import "fmt"

// Text fn
type Text string

func (t Text) String() string {
    return string(t)
}

func main() {
    fmt.Println(Text("hi world").String())
}

I made a early assumption that all method receivers are structs. Need to back out of this now, so method.Recv() returns a Typer. More specifically, Also need to change it so Structer is type of Typer and update the breakage there:

var _ Typer = (*structdef)(nil)

Inside: