From 39301e9f8b44ac8d1a024c5619eb5a302d47ff97 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 1 Oct 2021 18:37:28 -0700 Subject: [PATCH] Remove deprecated equals error (#985) --- src/compile_error.rs | 10 ---------- src/compile_error_kind.rs | 1 - src/parser.rs | 18 +---------------- tests/equals.rs | 29 +++++++++++++++++++++++++++ tests/lib.rs | 1 + tests/misc.rs | 42 ++------------------------------------- 6 files changed, 33 insertions(+), 68 deletions(-) create mode 100644 tests/equals.rs diff --git a/src/compile_error.rs b/src/compile_error.rs index 21d856c1..2f49923a 100644 --- a/src/compile_error.rs +++ b/src/compile_error.rs @@ -80,16 +80,6 @@ impl Display for CompileError<'_> { write!(f, "at most {} {}", max, Count("argument", *max))?; } } - DeprecatedEquals => { - writeln!( - f, - "`=` in assignments, exports, and aliases has been phased out on favor of `:=`" - )?; - write!( - f, - "Please see this issue for more details: https://github.com/casey/just/issues/379" - )?; - } DuplicateAlias { alias, first } => { write!( f, diff --git a/src/compile_error_kind.rs b/src/compile_error_kind.rs index af471070..dfe33c14 100644 --- a/src/compile_error_kind.rs +++ b/src/compile_error_kind.rs @@ -21,7 +21,6 @@ pub(crate) enum CompileErrorKind<'src> { min: usize, max: usize, }, - DeprecatedEquals, DuplicateAlias { alias: &'src str, first: usize, diff --git a/src/parser.rs b/src/parser.rs index 90533d6d..43118c6a 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -112,14 +112,6 @@ impl<'tokens, 'src> Parser<'tokens, 'src> { true } - /// Get the `n`th next significant token - fn get(&self, n: usize) -> CompileResult<'src, Token<'src>> { - match self.rest().nth(n) { - Some(token) => Ok(token), - None => Err(self.internal_error("`Parser::get()` advanced past end of token stream")?), - } - } - /// Advance past one significant token, clearing the expected token set. fn advance(&mut self) -> CompileResult<'src, Token<'src>> { self.expected.clear(); @@ -323,15 +315,9 @@ impl<'tokens, 'src> Parser<'tokens, 'src> { break; } else if self.next_is(Identifier) { match Keyword::from_lexeme(next.lexeme()) { - Some(Keyword::Alias) if self.next_are(&[Identifier, Identifier, Equals]) => { - return Err(self.get(2)?.error(CompileErrorKind::DeprecatedEquals)) - } Some(Keyword::Alias) if self.next_are(&[Identifier, Identifier, ColonEquals]) => { items.push(Item::Alias(self.parse_alias()?)); } - Some(Keyword::Export) if self.next_are(&[Identifier, Identifier, Equals]) => { - return Err(self.get(2)?.error(CompileErrorKind::DeprecatedEquals)) - } Some(Keyword::Export) if self.next_are(&[Identifier, Identifier, ColonEquals]) => { self.presume_keyword(Keyword::Export)?; items.push(Item::Assignment(self.parse_assignment(true)?)); @@ -344,9 +330,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> { items.push(Item::Set(self.parse_set()?)); } _ => { - if self.next_are(&[Identifier, Equals]) { - return Err(self.get(1)?.error(CompileErrorKind::DeprecatedEquals)); - } else if self.next_are(&[Identifier, ColonEquals]) { + if self.next_are(&[Identifier, ColonEquals]) { items.push(Item::Assignment(self.parse_assignment(false)?)); } else { let doc = pop_doc_comment(&mut items, eol_since_last_comment); diff --git a/tests/equals.rs b/tests/equals.rs new file mode 100644 index 00000000..476cea6b --- /dev/null +++ b/tests/equals.rs @@ -0,0 +1,29 @@ +use crate::common::*; + +#[test] +fn export_recipe() { + Test::new() + .justfile( + " + export foo='bar': + echo {{foo}} + ", + ) + .stdout("bar\n") + .stderr("echo bar\n") + .run(); +} + +#[test] +fn alias_recipe() { + Test::new() + .justfile( + " + alias foo='bar': + echo {{foo}} + ", + ) + .stdout("bar\n") + .stderr("echo bar\n") + .run(); +} diff --git a/tests/lib.rs b/tests/lib.rs index f35d878d..6f395d65 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -12,6 +12,7 @@ mod conditional; mod delimiters; mod dotenv; mod edit; +mod equals; mod error_messages; mod evaluate; mod examples; diff --git a/tests/misc.rs b/tests/misc.rs index 1a478801..a8c6fe2a 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -1831,7 +1831,7 @@ default a=`read A && echo $A` b=`read B && echo $B`: } test! { - name: equals_deprecated_assignment, + name: old_equals_assignment_syntax_produces_error, justfile: " foo = 'bar' @@ -1839,49 +1839,11 @@ test! { echo {{foo}} ", stderr: " - error: `=` in assignments, exports, and aliases has been phased out on favor of `:=` - Please see this issue for more details: https://github.com/casey/just/issues/379 + error: Expected '*', ':', '$', identifier, or '+', but found '=' | 1 | foo = 'bar' | ^ - ", - status: EXIT_FAILURE, -} - -test! { - name: equals_deprecated_export, - justfile: " - export FOO = 'bar' - - default: - echo $FOO ", - stderr: " - error: `=` in assignments, exports, and aliases has been phased out on favor of `:=` - Please see this issue for more details: https://github.com/casey/just/issues/379 - | - 1 | export FOO = 'bar' - | ^ - ", - status: EXIT_FAILURE, -} - -test! { - name: equals_deprecated_alias, - justfile: " - alias foo = default - - default: - echo default - ", - args: ("foo"), - stderr: " - error: `=` in assignments, exports, and aliases has been phased out on favor of `:=` - Please see this issue for more details: https://github.com/casey/just/issues/379 - | - 1 | alias foo = default - | ^ - ", status: EXIT_FAILURE, }