Skip to content

Commit dd97925

Browse files
authored
Fix unexport syntax conflicts (#2158)
1 parent e6c37aa commit dd97925

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/parser.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,13 @@ impl<'run, 'src> Parser<'run, 'src> {
340340
self.presume_keyword(Keyword::Export)?;
341341
items.push(Item::Assignment(self.parse_assignment(true)?));
342342
}
343-
Some(Keyword::Unexport) => {
343+
Some(Keyword::Unexport)
344+
if self.next_are(&[Identifier, Identifier, Eof])
345+
|| self.next_are(&[Identifier, Identifier, Eol]) =>
346+
{
344347
self.presume_keyword(Keyword::Unexport)?;
345348
let name = self.parse_name()?;
349+
self.expect_eol()?;
346350
items.push(Item::Unexport { name });
347351
}
348352
Some(Keyword::Import)

tests/unexport.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,28 @@ fn unexport_doesnt_override_local_recipe_export() {
9999
)
100100
.args(["recipe", "value"])
101101
.stdout("variable: value\n")
102-
.status(0)
102+
.run();
103+
}
104+
105+
#[test]
106+
fn unexport_does_not_conflict_with_recipe_syntax() {
107+
Test::new()
108+
.justfile(
109+
"
110+
unexport foo:
111+
@echo {{foo}}
112+
",
113+
)
114+
.args(["unexport", "bar"])
115+
.stdout("bar\n")
116+
.run();
117+
}
118+
119+
#[test]
120+
fn unexport_does_not_conflict_with_assignment_syntax() {
121+
Test::new()
122+
.justfile("unexport := 'foo'")
123+
.args(["--evaluate", "unexport"])
124+
.stdout("foo")
103125
.run();
104126
}

0 commit comments

Comments
 (0)