mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 12:33:42 +00:00
compiler: fix difference in aliases in interface methods
There used to be a difference between `byte` and `uint8` in interface methods. These are aliases, so they should be treated the same. This patch introduces a custom serialization format for types, circumventing the `Type.String()` method that is slightly wrong for our purposes. This also fixes an issue with the `any` keyword in Go 1.18, which suffers from the same problem (but this time actually leads to a crash).
This commit is contained in:
committed by
Ron Evans
parent
7af24c7864
commit
c0d257d682
Vendored
+11
@@ -40,6 +40,9 @@ func main() {
|
||||
// https://github.com/tinygo-org/tinygo/issues/453
|
||||
_, _ = itf.(Empty)
|
||||
|
||||
var v Byter = FooByte(3)
|
||||
println("Byte(): ", v.Byte())
|
||||
|
||||
var n int
|
||||
var f float32
|
||||
var interfaceEqualTests = []struct {
|
||||
@@ -266,3 +269,11 @@ type StaticBlocker interface {
|
||||
}
|
||||
|
||||
type Empty interface{}
|
||||
|
||||
type FooByte int
|
||||
|
||||
func (f FooByte) Byte() byte { return byte(f) }
|
||||
|
||||
type Byter interface {
|
||||
Byte() uint8
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -20,6 +20,7 @@ Stringer.String(): foo
|
||||
Stringer.(*Thing).String(): foo
|
||||
s has String() method: foo
|
||||
nested switch: true
|
||||
Byte(): 3
|
||||
non-blocking call on sometimes-blocking interface
|
||||
slept 1ms
|
||||
slept 1ms
|
||||
|
||||
Reference in New Issue
Block a user