[BUG] Subtraction not working when using positional argument + named argument
Description
Subtraction function does not work while using argument + named argument. If this should be the case, the error message should be updated.
With named argument
.var {a} {15}
.var {b} {8}
- Addition: .a + .b = **.sum {.a} {.b}**
- Subtraction: .a - .b = **.subtract {.a} from:{.b}**
Without named argument
.var {a} {15}
.var {b} {8}
- Addition: .a + .b = **.sum {.a} {.b}**
- Subtraction: .a - .b = **.subtract {.a} {.b}**
Hi @imLymei, thank you for reporting. That's possibly because .subtract's from parameter is the second one, positionally speaking. The issue can be generalized to an incorrect binding when mixing positional and named arguments.
As a side note, coincidentally enough, I already planned to remove the name from to avoid confusion, but I didn't really think of your approach.
I believe you would also be interested in the function call chaining syntax: for instance .sum {.a} {.b} can be rewritten as .a::sum {.b}.
Okay, after some thinking I realized your proposed syntax could be ambiguous. Consider the function signature f(a, b), then calling .f {0} a:{1} would be confusing for both the compiler and humans. I will just provide a clearer error message.
Done!
New message when calling .subtract {1} from:{3}:
Cannot call function subtract(Number from, Number b) with arguments (1, 3): parameter 'from' is already bound, but was attempted to be bound again to 3
I believe you would also be interested in the function call chaining syntax: for instance
.sum {.a} {.b}can be rewritten as.a::sum {.b}.
THANKS! That's definitely better!