diff options
author | wszqkzqk <wszqkzqk@qq.com> | 2022-12-13 21:56:53 +0800 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2022-12-22 17:13:52 +0100 |
commit | c5679d09cdc8b49c9b886fc6617db901350c301d (patch) | |
tree | a75445dfdeaef656e8c03140f793028c3e746369 /codegen | |
parent | a67d19f51082944e3751760d6c0ae09efc35b860 (diff) | |
download | vala-c5679d09cdc8b49c9b886fc6617db901350c301d.tar.gz |
parser: Properly handle chained equality expressions
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1385
Diffstat (limited to 'codegen')
-rw-r--r-- | codegen/valaccodebasemodule.vala | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 2969679c9..c8301c821 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -5842,8 +5842,17 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { } } - bool is_string_comparison = !(expr.left.value_type is NullType) && expr.left.value_type.compatible (string_type) - && !(expr.right.value_type is NullType) && expr.right.value_type.compatible (string_type); + bool is_string_comparison = false; + if (!(expr.right.value_type is NullType) && expr.right.value_type.compatible (string_type)) { + if (!(expr.left.value_type is NullType) && expr.left.value_type.compatible (string_type)) { + is_string_comparison = true; + } else if (expr.is_chained) { + unowned BinaryExpression lbe = (BinaryExpression) expr.left; + if (!(lbe.right.value_type is NullType) && lbe.right.value_type.compatible (string_type)) { + is_string_comparison = true; + } + } + } bool has_string_literal = (expr.left is StringLiteral || expr.right is StringLiteral); if (is_string_comparison || (has_string_literal && expr.operator != BinaryOperator.PLUS)) { |