rhaiscript / lsp

Language server for Rhai.
Apache License 2.0
43 stars 4 forks source link

`in` as an operator #48

Closed tamasfe closed 2 years ago

tamasfe commented 2 years ago

We should parse in just as an operator for the sake of simplicity, then restrict its usability in the HIR where needed.

schungx commented 2 years ago

Well, it actually is an operator. It is parsed like a normal operator, except that internally it gets turned into a call to contains with the operands switched. But syntax wise, it is an operator.

It does have a different precedence though.

tamasfe commented 2 years ago

I assigned the lowest binding power to it for now which is just above the default user-provided ones. (yeah it's now possible to provide custom operators that are valid identifiers).

schungx commented 2 years ago

I assigned the lowest binding power to it for now

Precedence of the in operator is defined here: https://rhai.rs/book/engine/custom-op.html#operator-precedence