Skip to content

Commit 18c1212

Browse files
authored
🐛 mqlc: missing float builtin comparison (#5537)
When trying to compare a float with an integer, users will get this error: ``` cannot find operator handler: float == int ``` This adds the missing comparison. Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
1 parent 3459dbf commit 18c1212

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

llx/builtin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ func init() {
182182
// == / !=
183183
string("==" + types.Nil): {f: floatCmpNilV2, Label: "=="},
184184
string("!=" + types.Nil): {f: floatNotNilV2, Label: "!="},
185+
string("==" + types.Int): {f: floatCmpIntV2, Label: "=="},
186+
string("!=" + types.Int): {f: floatNotIntV2, Label: "!="},
185187
string("==" + types.Float): {f: floatCmpFloatV2, Label: "=="},
186188
string("!=" + types.Float): {f: floatNotFloatV2, Label: "!="},
187189
string("==" + types.String): {f: floatCmpStringV2, Label: "=="},

providers/core/resources/mql_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ func TestCore_If(t *testing.T) {
8484
Code: "if (false) { return 123 } if (false) { return 456 } return 789",
8585
Expectation: int64(789),
8686
},
87+
{
88+
Code: "if (1.0 == 1) { return 123 } return 456",
89+
Expectation: int64(123),
90+
},
8791
{
8892
// This test comes out from an issue we had where return was not
8993
// generating a single entrypoint, causing the first reported

0 commit comments

Comments
 (0)