aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/interface.go
AgeCommit message (Collapse)Author
2023-11-08compiler: fix crash on type assert on interfaces with no methodsDamian Gryski
2023-06-09compiler,transform: fix for pointer-to-pointer type switches from @aykevlDamian Gryski
2023-03-21compiler: correctly generate code for local named typesAyke van Laethem
It is possible to create function-local named types: func foo() any { type named int return named(0) } This patch makes sure they don't alias with named types declared at the package scope. Bug originally found by Damian Gryski while working on reflect support.
2022-04-07compiler: fix difference in aliases in interface methodsAyke van Laethem
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).
2020-03-29compiler: add support for anonymous type assertsAyke van Laethem
This is used for example by the errors package, which contains: if x, ok := err.(interface{ As(interface{}) bool }); ok && x.As(target) { return true } The interface here is not a named type.
2020-03-20interp: add support for constant type assertsAyke van Laethem
Non-constant type asserts are not yet implemented, but should be relatively easy to add at a later time. They should result in a clear error message for now.
2019-12-26compiler: fix assertion on empty interfaceAyke van Laethem
This fixes issue #453.
2019-11-17compiler: add support for async interface callsJaden Weiss
2019-11-09runtime: implement comparing uintptr values in interfacesAyke van Laethem
This was an oversight in https://github.com/tinygo-org/tinygo/pull/686. With this PR, it's possible to compare interface values that contain values/fields of type uintptr.
2019-11-04runtime: implement interface equalityKonstantin Itskov
Code copied from Konstantin Itskov and modified by Ayke van Laethem. For details: https://github.com/tinygo-org/tinygo/pull/569
2019-08-08compiler: make struct types more uniqueAyke van Laethem
There are a lot more fields that are important when comparing structs with each other. Take them into account when building the unique ID per struct type. Example code that differs between the compilers: https://play.golang.org/p/nDX4tSHOf_T
2019-08-05compiler: fix crash with linked lists in interfacesAyke van Laethem
This commit fixes the following issue: https://github.com/tinygo-org/tinygo/issues/309 Also, it prepares for some other reflect-related changes that should make it easier to add support for named types (etc.) in the future.
2018-12-01compiler: lower interfaces in a separate passAyke van Laethem
This commit changes many things: * Most interface-related operations are moved into an optimization pass for more modularity. IR construction creates pseudo-calls which are lowered in this pass. * Type codes are assigned in this interface lowering pass, after DCE. * Type codes are sorted by usage: types more often used in type asserts are assigned lower numbers to ease jump table construction during machine code generation. * Interface assertions are optimized: they are replaced by constant false, comparison against a constant, or a typeswitch with only concrete types in the general case. * Interface calls are replaced with unreachable, direct calls, or a concrete type switch with direct calls depending on the number of implementing types. This hopefully makes some interface patterns zero-cost. These changes lead to a ~0.5K reduction in code size on Cortex-M for testdata/interface.go. It appears that a major cause for this is the replacement of function pointers with direct calls, which are far more susceptible to optimization. Also, not having a fixed global array of function pointers greatly helps dead code elimination. This change also makes future optimizations easier, like optimizations on interface value comparisons.
2018-10-23compiler: fix invalid incoming block in complex typeassert flowAyke van Laethem
A single *ssa.BasicBlock may be split in multiple LLVM basic blocks due to typeassert instructions. This means the incoming block and outgoing block are different. PHI nodes need to get the result from the outgoing block, which was fixed before, but incoming branches need to branch to the incoming block, not the outgoing block. Branching to the outgoing block led to a LLVM verification error when compiling the fmt package. Originally found in (*fmt.pp).handleMethods.
2018-10-07main: extra interface test for simple named typesAyke van Laethem
2018-10-07compiler: fix expanded structs in invoke callsAyke van Laethem
2018-10-07compiler: fix interface calls for big underlying valuesAyke van Laethem
When the underlying value of an interface does not fit in a pointer, a pointer to the value was correctly inserted in the heap. However, the receiving method still assumed it got the underlying value instead of a pointer to it leading to a crash. This commit inserts wrapper functions for method calls on interfaces. The bug wasn't obvious as on a 64-bit system, the underlying value was almost always put directly in the interface. However, it led to a crash on the AVR platform where pointer are (usually) just 16 bits making it far more likely that underlying values cannot be directly stored in an interface.