mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Let let-binding raise error on unexpected keywords (#4034)
This commit is contained in:
parent
eac2200c97
commit
44bc51ba4f
@ -1452,12 +1452,11 @@ fn pattern_leaf<'s>(
|
|||||||
seen: &mut HashSet<&'s str>,
|
seen: &mut HashSet<&'s str>,
|
||||||
dupe: Option<&'s str>,
|
dupe: Option<&'s str>,
|
||||||
) {
|
) {
|
||||||
if !p.at_set(set::PATTERN_LEAF) {
|
if p.current().is_keyword() {
|
||||||
if p.current().is_keyword() {
|
p.eat_and_get().expected("pattern");
|
||||||
p.eat_and_get().expected("pattern");
|
return;
|
||||||
} else {
|
} else if !p.at_set(set::PATTERN_LEAF) {
|
||||||
p.expected("pattern");
|
p.expected("pattern");
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,3 +141,20 @@ Three
|
|||||||
// ... where this wasn't.
|
// ... where this wasn't.
|
||||||
// Error: 12 expected equals sign
|
// Error: 12 expected equals sign
|
||||||
#let (a, b)
|
#let (a, b)
|
||||||
|
|
||||||
|
--- issue-4027-let-binding-with-keyword-context ---
|
||||||
|
// Error: 6-13 expected pattern, found keyword `context`
|
||||||
|
// Hint: 6-13 keyword `context` is not allowed as an identifier; try `context_` instead
|
||||||
|
#let context = 5
|
||||||
|
|
||||||
|
--- issue-4027-let-binding-with-keyword-let ---
|
||||||
|
// Error: 6-9 expected pattern, found keyword `let`
|
||||||
|
// Hint: 6-9 keyword `let` is not allowed as an identifier; try `let_` instead
|
||||||
|
#let let = 5
|
||||||
|
|
||||||
|
--- issue-4027-let-binding-with-destructured-keywords ---
|
||||||
|
// Error: 7-14 expected pattern, found keyword `context`
|
||||||
|
// Hint: 7-14 keyword `context` is not allowed as an identifier; try `context_` instead
|
||||||
|
// Error: 21-24 expected pattern, found keyword `let`
|
||||||
|
// Hint: 21-24 keyword `let` is not allowed as an identifier; try `let_` instead
|
||||||
|
#let (context, foo, let) = (5, 6, 7)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user