Skip to content

Commit

Permalink
cl: builtin add type alias any = interface{}
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Jan 18, 2022
1 parent 87f6e91 commit c7ec887
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions cl/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func initBuiltin(pkg gox.PkgImporter, builtin *types.Package, fmt, big *gox.PkgR
scope.Insert(gox.NewOverloadFunc(token.NoPos, builtin, fn, fmt.Ref(fnTitle)))
}
scope.Insert(gox.NewOverloadFunc(token.NoPos, builtin, "newRange", big.Ref("NewRange__0")))
scope.Insert(types.NewTypeName(token.NoPos, builtin, "any", gox.TyEmptyInterface))
}

func newBuiltinDefault(pkg gox.PkgImporter, conf *gox.Config) *types.Package {
Expand Down
17 changes: 17 additions & 0 deletions cl/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3602,3 +3602,20 @@ func main() {
}
`)
}

func TestAnyAlias(t *testing.T) {
gopClTest(t, `
var a any = 100
println(a)
`, `package main
import fmt "fmt"
var a interface {
} = 100
func main() {
fmt.Println(a)
}
`)
}

0 comments on commit c7ec887

Please sign in to comment.