Remove python-like string multiplication (#10293)

# Description
Currently we support "multiplication" of strings, resulting in a terse
way to repeat a particular string.
This can have unintended side effects when dealing with mixed data (e.g.
after parsing data that is not all numbers).
Furthermore as we frequently fall-back to strings while parsing source
code, this introduced a runaway edge case in const evaluation (#10212)

Work for #10233

## Details
- Remove python-like string multiplication.
- Workaround for indentation
  - This should probably be addressed with a purpose built command
- Remove special const-eval error test

# User-Facing Changes
**Major breaking change!**
`"string" * 42` will stop working. (This was used for example in the
stdlib)

We should bless a good alternative before landing this

---------

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
This commit is contained in:
Stefan Holderbach
2023-09-13 09:52:04 +02:00
committed by GitHub
parent a14e9e0a2e
commit 7f39609d9a
7 changed files with 10 additions and 43 deletions

View File

@ -415,16 +415,6 @@ pub fn eval_constant(
}
}
Operator::Math(math) => {
match (&math, &lhs.expr, &rhs.expr) {
// Multiple may generate super long string
// and stop the whole shell while highlighting
// e.g. '2 ** 60 * a'
(Math::Multiply, Expr::String(..), _)
| (Math::Multiply, _, Expr::String(..)) => {
return Err(ShellError::NotAConstant(expr.span))
}
_ => {}
}
let lhs = eval_constant(working_set, lhs)?;
let rhs = eval_constant(working_set, rhs)?;