summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/model/func.rs10
-rw-r--r--src/model/value.rs2
-rw-r--r--src/syntax/parser.rs7
3 files changed, 13 insertions, 6 deletions
diff --git a/src/model/func.rs b/src/model/func.rs
index c5bab64c..9583f6fd 100644
--- a/src/model/func.rs
+++ b/src/model/func.rs
@@ -517,16 +517,16 @@ mod tests {
fn test_captures() {
// Let binding and function definition.
test("#let x = x", &["x"]);
- test("#let x; #{x + y}", &["y"]);
+ test("#let x; #(x + y)", &["y"]);
test("#let f(x, y) = x + y", &[]);
test("#let f(x, y) = f", &[]);
test("#let f = (x, y) => f", &["f"]);
// Closure with different kinds of params.
- test("#{(x, y) => x + z}", &["z"]);
- test("#{(x: y, z) => x + z}", &["y"]);
- test("#{(..x) => x + y}", &["y"]);
- test("#{(x, y: x + z) => x + y}", &["x", "z"]);
+ test("#((x, y) => x + z)", &["z"]);
+ test("#((x: y, z) => x + z)", &["y"]);
+ test("#((..x) => x + y)", &["y"]);
+ test("#((x, y: x + z) => x + y)", &["x", "z"]);
test("#{x => x; x}", &["x"]);
// Show rule.
diff --git a/src/model/value.rs b/src/model/value.rs
index b860a3f6..dff27fde 100644
--- a/src/model/value.rs
+++ b/src/model/value.rs
@@ -133,7 +133,7 @@ impl Value {
format_str!("{:?}", self)
}
- /// Attach a span to the value, if possibly.
+ /// Attach a span to the value, if possible.
pub fn spanned(self, span: Span) -> Self {
match self {
Value::Content(v) => Value::Content(v.spanned(span)),
diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs
index cd318983..d966df98 100644
--- a/src/syntax/parser.rs
+++ b/src/syntax/parser.rs
@@ -521,7 +521,14 @@ fn embedded_code_expr(p: &mut Parser) {
| SyntaxKind::Include
);
+ let prev = p.prev_end();
code_expr_prec(p, true, 0);
+
+ // Consume error for things like `#12p` or `#"abc\"`.
+ if !p.progress(prev) {
+ p.unexpected();
+ }
+
let semi = p.eat_if(SyntaxKind::Semicolon);
if stmt && !semi && !p.eof() && !p.at(SyntaxKind::RightBracket) {
p.expected("semicolon or line break");