diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 923997bf6..61a93c718 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -309,6 +309,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err %token IND_STRING_OPEN IND_STRING_CLOSE %token ELLIPSIS +%right '$' %right IMPL %left OR %left AND @@ -377,6 +378,7 @@ expr_op | expr_op '*' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__mul")), {$1, $3}); } | expr_op '/' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__div")), {$1, $3}); } | expr_op CONCAT expr_op { $$ = new ExprOpConcatLists(CUR_POS, $1, $3); } + | expr_op '$' expr_op { $$ = new ExprCall(CUR_POS, $1, {$3}); } | expr_app { $$ = $1.e; } ; diff --git a/tests/lang/eval-fail-function-apply-dollar.nix b/tests/lang/eval-fail-function-apply-dollar.nix new file mode 100644 index 000000000..805146f6d --- /dev/null +++ b/tests/lang/eval-fail-function-apply-dollar.nix @@ -0,0 +1,6 @@ +let + a = 5; + b = 1; + + add = a: b: a + b; +in add a $ a $ b diff --git a/tests/lang/eval-okay-function-apply-dollar.exp b/tests/lang/eval-okay-function-apply-dollar.exp new file mode 100644 index 000000000..3c032078a --- /dev/null +++ b/tests/lang/eval-okay-function-apply-dollar.exp @@ -0,0 +1 @@ +18 diff --git a/tests/lang/eval-okay-function-apply-dollar.nix b/tests/lang/eval-okay-function-apply-dollar.nix new file mode 100644 index 000000000..f860ffd17 --- /dev/null +++ b/tests/lang/eval-okay-function-apply-dollar.nix @@ -0,0 +1,9 @@ +let + a = 5; + b = 1; + c = 2; + concat = a: b: "${a}${b}"; + nested.attr.ab = 10; + + add = a: b: a + b; +in add nested.attr.${concat "a" "b"} $ add b $ add a c