Search code examples
rakuoperator-precedencerakudo

Precedence inside a function call


Using the defined-or operator ( // ) in a function call produces the result I'd expect:

say( 'nan'.Int // 42); # OUTPUT: «42»

However, using the lower-precedence orelse operator instead throws an error:

say( 'nan'.Int orelse 42); 
# OUTPUT: «Error: Unable to parse expression in argument list; 
#                 couldn't find final ')' 
#                 (corresponding starter was at line 1)»

What am I missing about how precedence works?

(Or is the error a bug and I'm just overthinking this?)


Solution

  • I'd say, it's a grammar bug, as

    say ("nan".Int orelse 42);  # 42
    

    works.