cgen: materialise str-def operands in streq pushes
A str `def` has no name(SB) header; the streq push arms read a frame slot that does not exist. Load the literal through cgexpr (AX=ptr, BX=len) instead. Both stages.
This commit is contained in:
20
test/lang/str_def_equality_test.ww
Normal file
20
test/lang/str_def_equality_test.ww
Normal file
@@ -0,0 +1,20 @@
|
||||
// String equality must materialise a module def literal instead of treating
|
||||
// its name as a frame-local string header. Use a duplicated local so pointer
|
||||
// equality cannot accidentally satisfy the content comparison.
|
||||
|
||||
package str_def_equality_test;
|
||||
|
||||
import strings;
|
||||
|
||||
def expected: str = "dynamic string versus def";
|
||||
|
||||
@test fn dynamic_string_and_def_compare_by_content() void = {
|
||||
let observed: str = strings.dup(expected);
|
||||
assert(observed == expected);
|
||||
assert(expected == observed);
|
||||
assert(!(observed != expected));
|
||||
assert(!(expected != observed));
|
||||
let different: str = strings.concat(observed, "!");
|
||||
assert(different != expected);
|
||||
assert(expected != different);
|
||||
};
|
||||
Reference in New Issue
Block a user