mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-09 22:58:01 +00:00
Remove deprecated string interpolation syntax
This commit is contained in:
parent
72011fba73
commit
cb98c45e88
15 changed files with 17 additions and 94 deletions
|
@ -1045,20 +1045,6 @@ fn desugar_str_segments<'a>(
|
|||
StrSegment::Plaintext(_) | StrSegment::Unicode(_) | StrSegment::EscapedChar(_) => {
|
||||
*segment
|
||||
}
|
||||
StrSegment::DeprecatedInterpolated(loc_expr) => {
|
||||
let loc_desugared = desugar_expr(
|
||||
env,
|
||||
scope,
|
||||
env.arena.alloc(Loc {
|
||||
region: loc_expr.region,
|
||||
value: *loc_expr.value,
|
||||
}),
|
||||
);
|
||||
StrSegment::DeprecatedInterpolated(Loc {
|
||||
region: loc_desugared.region,
|
||||
value: env.arena.alloc(loc_desugared.value),
|
||||
})
|
||||
}
|
||||
StrSegment::Interpolated(loc_expr) => {
|
||||
let loc_desugared = desugar_expr(
|
||||
env,
|
||||
|
|
|
@ -2515,9 +2515,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
|
|||
| ast::StrSegment::Plaintext(_) => true,
|
||||
// Disallow nested interpolation. Alternatively, we could allow it but require
|
||||
// a comment above it apologizing to the next person who has to read the code.
|
||||
ast::StrSegment::Interpolated(_) | ast::StrSegment::DeprecatedInterpolated(_) => {
|
||||
false
|
||||
}
|
||||
ast::StrSegment::Interpolated(_) => false,
|
||||
})
|
||||
}
|
||||
ast::Expr::Record(fields) => fields.iter().all(|loc_field| match loc_field.value {
|
||||
|
@ -2648,7 +2646,7 @@ fn flatten_str_lines<'a>(
|
|||
);
|
||||
}
|
||||
},
|
||||
Interpolated(loc_expr) | DeprecatedInterpolated(loc_expr) => {
|
||||
Interpolated(loc_expr) => {
|
||||
if is_valid_interpolation(loc_expr.value) {
|
||||
// Interpolations desugar to Str.concat calls
|
||||
output.references.insert_call(Symbol::STR_CONCAT);
|
||||
|
|
|
@ -1109,7 +1109,7 @@ fn flatten_str_lines(lines: &[&[StrSegment<'_>]]) -> Pattern {
|
|||
Unicode(loc_digits) => {
|
||||
todo!("parse unicode digits {:?}", loc_digits);
|
||||
}
|
||||
Interpolated(loc_expr) | DeprecatedInterpolated(loc_expr) => {
|
||||
Interpolated(loc_expr) => {
|
||||
return Pattern::UnsupportedPattern(loc_expr.region);
|
||||
}
|
||||
EscapedChar(escaped) => buf.push(escaped.unescape()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue