diff options
author | Ayke van Laethem <[email protected]> | 2022-04-06 21:22:04 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-04-07 12:54:17 +0200 |
commit | c0d257d68217ae9af36489f2b39a23314f8c4fdc (patch) | |
tree | d3bb8dfa0d406ca8d62bc6fb64f28249cdff4566 /testdata/interface.go | |
parent | 7af24c786421eef4c34435c9ecb4184df0b40307 (diff) | |
download | tinygo-c0d257d68217ae9af36489f2b39a23314f8c4fdc.tar.gz tinygo-c0d257d68217ae9af36489f2b39a23314f8c4fdc.zip |
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).
Diffstat (limited to 'testdata/interface.go')
-rw-r--r-- | testdata/interface.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/testdata/interface.go b/testdata/interface.go index 0f66a30e5..d13399f36 100644 --- a/testdata/interface.go +++ b/testdata/interface.go @@ -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 +} |