RX0167

Domain: Parsing

Error message

`if` where a value belongs: %s (%s)

In the message, %s marks a value that the engine fills in when it raises the error.

The story

You tried to use an if as if it were a value, and the engine corrected you. In some languages, an if can be an expression: you write x equals, if ok, yes, else no. In rush, if is a flow. A flow contains statements and routes between them. It does not produce a value, so there is nothing for x to receive. Instead of a confusing message that says the name if locates nothing, the engine now teaches you the right way. Bind inside each branch. Write if ok, then on the next line, indented, x equals yes. Then else, and underneath, x equals no. The branches do the binding, and the name belongs to the module. It is a little longer, but each branch is a clear statement, with nothing hidden inside an expression. The message shows where the problem was written. Rewrite it with the branches binding, and the code does exactly what you meant, in a shape the language is happy to run.

Text from the Rush engine's error catalogue.