mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 04:53:42 +00:00
compiler: fix invalid incoming block in complex typeassert flow
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.
This commit is contained in:
Vendored
+13
@@ -20,6 +20,8 @@ func main() {
|
||||
println("Stringer.String():", s.String())
|
||||
var itf interface{} = s
|
||||
println("Stringer.(*Thing).String():", itf.(Stringer).String())
|
||||
|
||||
println("nested switch:", nestedSwitch('v', 3))
|
||||
}
|
||||
|
||||
func printItf(val interface{}) {
|
||||
@@ -46,6 +48,17 @@ func printItf(val interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func nestedSwitch(verb rune, arg interface{}) bool {
|
||||
switch verb {
|
||||
case 'v', 's':
|
||||
switch arg.(type) {
|
||||
case int:
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type Thing struct {
|
||||
name string
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -16,3 +16,4 @@ is Tuple: 0 8 16 24
|
||||
SmallPair.Print: 3 5
|
||||
Stringer.String(): foo
|
||||
Stringer.(*Thing).String(): foo
|
||||
nested switch: true
|
||||
|
||||
Reference in New Issue
Block a user