cgen: fix fixed arrays literal eq (#8079)
parent
7458b699d0
commit
ae592299dc
|
@ -44,3 +44,17 @@ fn test_fixed_array_eq() {
|
||||||
assert a8 == [['aaa', 'bbb']!!, ['ccc', 'ddd']!!]
|
assert a8 == [['aaa', 'bbb']!!, ['ccc', 'ddd']!!]
|
||||||
assert a8 != [['bbb', 'aaa']!!, ['cccc', 'dddd']!!]
|
assert a8 != [['bbb', 'aaa']!!, ['cccc', 'dddd']!!]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_fixed_array_literal_eq() {
|
||||||
|
assert [1, 2, 3]! == [1, 2, 3]!
|
||||||
|
assert [1, 1, 1]! != [1, 2, 3]!
|
||||||
|
|
||||||
|
assert [[1, 2], [3, 4]]! == [[1, 2], [3, 4]]!
|
||||||
|
assert [[1, 1], [2, 2]]! != [[1, 2], [3, 4]]!
|
||||||
|
|
||||||
|
assert [[1, 1]!, [2, 2]!]! == [[1, 1]!, [2, 2]!]!
|
||||||
|
assert [[1, 1]!, [2, 2]!]! != [[1, 2]!, [2, 3]!]!
|
||||||
|
|
||||||
|
assert [[1, 1]!, [2, 2]!] == [[1, 1]!, [2, 2]!]
|
||||||
|
assert [[1, 1]!, [2, 2]!] != [[1, 2]!, [2, 3]!]
|
||||||
|
}
|
||||||
|
|
|
@ -3032,6 +3032,10 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
|
||||||
if node.left_type.is_ptr() {
|
if node.left_type.is_ptr() {
|
||||||
g.write('*')
|
g.write('*')
|
||||||
}
|
}
|
||||||
|
if node.left is ast.ArrayInit {
|
||||||
|
s := g.typ(left_type)
|
||||||
|
g.write('($s)')
|
||||||
|
}
|
||||||
g.expr(node.left)
|
g.expr(node.left)
|
||||||
g.write(', ')
|
g.write(', ')
|
||||||
if node.right is ast.ArrayInit {
|
if node.right is ast.ArrayInit {
|
||||||
|
|
Loading…
Reference in New Issue