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