handle () inside default value of function args

This commit is contained in:
ConnorSkees 2020-04-24 23:15:41 -04:00
parent f60089f4f9
commit 56f198f2a7
2 changed files with 9 additions and 3 deletions

View File

@ -241,10 +241,11 @@ pub(crate) fn eat_func_args<I: Iterator<Item = Token>>(
close_paren_span = tok.pos(); close_paren_span = tok.pos();
break; break;
} }
_ => { '(' => {
let tok = toks.next().expect("we know this exists!"); default.push(toks.next().unwrap());
default.push(tok) default.extend(read_until_closing_paren(toks));
} }
_ => default.push(toks.next().unwrap()),
} }
} }
} }

View File

@ -35,3 +35,8 @@ test!(
"$index: 1;\n\n@function foo($a) {\n @return $a;\n}\n\na {\n color: foo($index - 1);\n}\n", "$index: 1;\n\n@function foo($a) {\n @return $a;\n}\n\na {\n color: foo($index - 1);\n}\n",
"a {\n color: 0;\n}\n" "a {\n color: 0;\n}\n"
); );
test!(
parens_in_default_arg_value,
"@function foo($arg1: bar()) {\n @return true;\n}\n\na {\n color: foo();\n}\n",
"a {\n color: true;\n}\n"
);