purpleidea / mgmt

Next generation distributed, event-driven, parallel config management!
https://purpleidea.com/tags/mgmtconfig/
GNU General Public License v3.0
3.47k stars 308 forks source link

`in` can't be both a keyword and an identifier #728

Open purpleidea opened 6 months ago

purpleidea commented 6 months ago

I seem to have forgotten to add the following txtar test:

-- main.mcl --
$s = if 42 in [13, -5, 42, 0] { # make sure the `in` operator works
    "pass"
} else {
    "fail"
}

test $s {}
-- OUTPUT --
Vertex: test[pass]

Woops---

In commit 233625db200d453072f5a48a1d744b494fb6cbba

lang: parser: Lexer should allow in keyword as a variable name

It turns out I actually broke this. I didn't test properly, sorry!

Is it possible to have both? I don't think most languages allow this, but since we have a $ prefix, it should be easier to disambiguate things.

If so, fixup, if not, make that test failing and add the above test.

purpleidea commented 6 months ago

I've patched this in f92f34dc549774a1f47c1993e560145fa53197db but if there is a better solution I'd love to have it.