Remove deprecated equals error (#985)
This commit is contained in:
parent
93f88dc8cf
commit
39301e9f8b
@ -80,16 +80,6 @@ impl Display for CompileError<'_> {
|
|||||||
write!(f, "at most {} {}", max, Count("argument", *max))?;
|
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 } => {
|
DuplicateAlias { alias, first } => {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
|
@ -21,7 +21,6 @@ pub(crate) enum CompileErrorKind<'src> {
|
|||||||
min: usize,
|
min: usize,
|
||||||
max: usize,
|
max: usize,
|
||||||
},
|
},
|
||||||
DeprecatedEquals,
|
|
||||||
DuplicateAlias {
|
DuplicateAlias {
|
||||||
alias: &'src str,
|
alias: &'src str,
|
||||||
first: usize,
|
first: usize,
|
||||||
|
@ -112,14 +112,6 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
|
|||||||
true
|
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.
|
/// Advance past one significant token, clearing the expected token set.
|
||||||
fn advance(&mut self) -> CompileResult<'src, Token<'src>> {
|
fn advance(&mut self) -> CompileResult<'src, Token<'src>> {
|
||||||
self.expected.clear();
|
self.expected.clear();
|
||||||
@ -323,15 +315,9 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
|
|||||||
break;
|
break;
|
||||||
} else if self.next_is(Identifier) {
|
} else if self.next_is(Identifier) {
|
||||||
match Keyword::from_lexeme(next.lexeme()) {
|
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]) => {
|
Some(Keyword::Alias) if self.next_are(&[Identifier, Identifier, ColonEquals]) => {
|
||||||
items.push(Item::Alias(self.parse_alias()?));
|
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]) => {
|
Some(Keyword::Export) if self.next_are(&[Identifier, Identifier, ColonEquals]) => {
|
||||||
self.presume_keyword(Keyword::Export)?;
|
self.presume_keyword(Keyword::Export)?;
|
||||||
items.push(Item::Assignment(self.parse_assignment(true)?));
|
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()?));
|
items.push(Item::Set(self.parse_set()?));
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if self.next_are(&[Identifier, Equals]) {
|
if self.next_are(&[Identifier, ColonEquals]) {
|
||||||
return Err(self.get(1)?.error(CompileErrorKind::DeprecatedEquals));
|
|
||||||
} else if self.next_are(&[Identifier, ColonEquals]) {
|
|
||||||
items.push(Item::Assignment(self.parse_assignment(false)?));
|
items.push(Item::Assignment(self.parse_assignment(false)?));
|
||||||
} else {
|
} else {
|
||||||
let doc = pop_doc_comment(&mut items, eol_since_last_comment);
|
let doc = pop_doc_comment(&mut items, eol_since_last_comment);
|
||||||
|
29
tests/equals.rs
Normal file
29
tests/equals.rs
Normal 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();
|
||||||
|
}
|
@ -12,6 +12,7 @@ mod conditional;
|
|||||||
mod delimiters;
|
mod delimiters;
|
||||||
mod dotenv;
|
mod dotenv;
|
||||||
mod edit;
|
mod edit;
|
||||||
|
mod equals;
|
||||||
mod error_messages;
|
mod error_messages;
|
||||||
mod evaluate;
|
mod evaluate;
|
||||||
mod examples;
|
mod examples;
|
||||||
|
@ -1831,7 +1831,7 @@ default a=`read A && echo $A` b=`read B && echo $B`:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test! {
|
test! {
|
||||||
name: equals_deprecated_assignment,
|
name: old_equals_assignment_syntax_produces_error,
|
||||||
justfile: "
|
justfile: "
|
||||||
foo = 'bar'
|
foo = 'bar'
|
||||||
|
|
||||||
@ -1839,49 +1839,11 @@ test! {
|
|||||||
echo {{foo}}
|
echo {{foo}}
|
||||||
",
|
",
|
||||||
stderr: "
|
stderr: "
|
||||||
error: `=` in assignments, exports, and aliases has been phased out on favor of `:=`
|
error: Expected '*', ':', '$', identifier, or '+', but found '='
|
||||||
Please see this issue for more details: https://github.com/casey/just/issues/379
|
|
||||||
|
|
|
|
||||||
1 | foo = 'bar'
|
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,
|
status: EXIT_FAILURE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user