Remove deprecated equals error (#985)

This commit is contained in:
Casey Rodarmor 2021-10-01 18:37:28 -07:00 committed by GitHub
parent 93f88dc8cf
commit 39301e9f8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 68 deletions

View file

@ -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,

View file

@ -21,7 +21,6 @@ pub(crate) enum CompileErrorKind<'src> {
min: usize,
max: usize,
},
DeprecatedEquals,
DuplicateAlias {
alias: &'src str,
first: usize,

View file

@ -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);

29
tests/equals.rs Normal file
View file

@ -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();
}

View file

@ -12,6 +12,7 @@ mod conditional;
mod delimiters;
mod dotenv;
mod edit;
mod equals;
mod error_messages;
mod evaluate;
mod examples;

View file

@ -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,
}