Fix string interp/shorthand overlap (#3412)

This commit is contained in:
JT 2021-05-12 16:20:29 +12:00 committed by GitHub
parent 2bb23c57df
commit efac712f62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -1738,9 +1738,9 @@ fn expand_shorthand_forms(
lite_pipeline: &LitePipeline,
) -> (LitePipeline, Option<SpannedKeyValue>, Option<ParseError>) {
if !lite_pipeline.commands.is_empty() {
if lite_pipeline.commands[0].parts[0].item == "=" {
(lite_pipeline.clone(), None, None)
} else if lite_pipeline.commands[0].parts[0].contains('=') {
if lite_pipeline.commands[0].parts[0].contains('=')
&& !lite_pipeline.commands[0].parts[0].starts_with('$')
{
let assignment: Vec<_> = lite_pipeline.commands[0].parts[0].split('=').collect();
if assignment.len() != 2 {
(

View File

@ -137,6 +137,18 @@ fn string_interpolation_with_it_column_path() {
assert_eq!(actual.out, "sammie");
}
#[test]
fn string_interpolation_shorthand_overlap() {
let actual = nu!(
cwd: ".",
r#"
$"3 + 4 = {3 + 4}"
"#
);
assert_eq!(actual.out, "3 + 4 = 7");
}
#[test]
fn bignum_large_integer() {
let actual = nu!(