string_compare.mx raw
1 // Regression: string comparison passes wrong LLVM type to runtime.stringEqual.
2 //
3 // The SSA builder generated an SSACall to runtime.stringEqual with an
4 // argument whose SSAType resolved to i32 instead of {ptr,i64,i64} (the
5 // string/slice LLVM representation). clang rejected the IR:
6 // "error: '%t14' defined with type '{ ptr, i64, i64 }' but expected 'ptr'".
7 //
8 // Reproduces: string equality comparison with == operator.
9 // Fixed in: pkg/ssa builder (7-file → monolithic conversion).
10
11 package main
12
13 func main() {
14 a := "hello"
15 b := "hello"
16 if a == b {
17 println("ok")
18 }
19 if a != "nope" {
20 println("ok")
21 }
22 }
23