Skip to content

Commit

Permalink
Merge pull request #6488 from roc-lang/forgot-old-interpolation-syntax
Browse files Browse the repository at this point in the history
update to new interpolation syntax
  • Loading branch information
Anton-4 authored Feb 4, 2024
2 parents 8e3c159 + c72b2a5 commit b2b5587
Show file tree
Hide file tree
Showing 45 changed files with 402 additions and 402 deletions.
2 changes: 1 addition & 1 deletion crates/cli/tests/cli_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ mod cli_run {
provides [main] to pf
main =
Stdout.line "\nThis roc file can print it's own source code. The source is:\n\n\(ownCode)"
Stdout.line "\nThis roc file can print it's own source code. The source is:\n\n$(ownCode)"
"#
),
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/fixtures/packages/app.roc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ app "packages-test"
imports [json.JsonParser, csv.Csv]
provides [main] to pf

main = "Hello, World! \(JsonParser.example) \(Csv.example)"
main = "Hello, World! $(JsonParser.example) $(Csv.example)"
2 changes: 1 addition & 1 deletion crates/cli_testing_examples/benchmarks/Quicksort.roc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ show = \list ->
|> List.map Num.toStr
|> Str.joinWith ", "

"[\(content)]"
"[$(content)]"

sortBy : List a, (a -> Num *) -> List a
sortBy = \list, toComparable ->
Expand Down
4 changes: 2 additions & 2 deletions crates/cli_testing_examples/benchmarks/rBTreeInsert.roc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ showRBTree = \tree, showKey, showValue ->
sL = nodeInParens left showKey showValue
sR = nodeInParens right showKey showValue

"Node \(sColor) \(sKey) \(sValue) \(sL) \(sR)"
"Node $(sColor) $(sKey) $(sValue) $(sL) $(sR)"

nodeInParens : RedBlackTree k v, (k -> Str), (v -> Str) -> Str
nodeInParens = \tree, showKey, showValue ->
Expand All @@ -37,7 +37,7 @@ nodeInParens = \tree, showKey, showValue ->
Node _ _ _ _ _ ->
inner = showRBTree tree showKey showValue

"(\(inner))"
"($(inner))"

showColor : NodeColor -> Str
showColor = \color ->
Expand Down
2 changes: 1 addition & 1 deletion crates/cli_testing_examples/benchmarks/testAStar.roc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ main =
#
# _ ->
# ns = Num.toStr n
# Task.putLine "No test \(ns)"
# Task.putLine "No test $(ns)"
showBool : Bool -> Str
showBool = \b ->
if
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/builtins/roc/Dict.roc
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ increaseSize = \@Dict { data, maxBucketCapacity, maxLoadFactor, shifts } ->
shifts: newShifts,
}
else
crash "Dict hit limit of \(Num.toStr maxBucketCount) elements. Unable to grow more."
crash "Dict hit limit of $(Num.toStr maxBucketCount) elements. Unable to grow more."

allocBucketsFromShift : U8, F32 -> (List Bucket, U64)
allocBucketsFromShift = \shifts, maxLoadFactor ->
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/builtins/roc/Str.roc
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ replaceFirst : Str, Str, Str -> Str
replaceFirst = \haystack, needle, flower ->
when splitFirst haystack needle is
Ok { before, after } ->
"\(before)\(flower)\(after)"
"$(before)$(flower)$(after)"

Err NotFound -> haystack

Expand All @@ -862,7 +862,7 @@ replaceLast : Str, Str, Str -> Str
replaceLast = \haystack, needle, flower ->
when splitLast haystack needle is
Ok { before, after } ->
"\(before)\(flower)\(after)"
"$(before)$(flower)$(after)"

Err NotFound -> haystack

Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/can/tests/test_can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ mod test_can {
// "abcd\$(efg)hij"
// "#
// ),
// Str(r"abcd\(efg)hij".into()),
// Str(r"abcd$(efg)hij".into()),
// );
// }

Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/load/tests/test_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5549,15 +5549,15 @@ mod test_reporting {
r#"
greeting = "Privet"
if Bool.true then 1 else "\(greeting), World!"
if Bool.true then 1 else "$(greeting), World!"
"#,
),
@r#"
── TYPE MISMATCH in /code/proj/Main.roc ────────────────────────────────────────
This `if` has an `else` branch with a different type from its `then` branch:
6│ if Bool.true then 1 else "\(greeting), World!"
6│ if Bool.true then 1 else "$(greeting), World!"
^^^^^^^^^^^^^^^^^^^^^
The `else` branch is a string of type:
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/module/src/called_via.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub enum CalledVia {
UnaryOp(UnaryOp),

/// This call is the result of desugaring string interpolation,
/// e.g. "\(first) \(last)" is transformed into Str.concat (Str.concat first " ") last.
/// e.g. "$(first) $(last)" is transformed into Str.concat (Str.concat first " ") last.
StringInterpolation,

/// This call is the result of desugaring a Record Builder field.
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler/solve/tests/solve_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ mod solve_expr {
r#"
whatItIs = "great"
"type inference is \(whatItIs)!"
"type inference is $(whatItIs)!"
"#
),
"Str",
Expand All @@ -326,7 +326,7 @@ mod solve_expr {
r#"
whatItIs = "great"
str = "type inference is \(whatItIs)!"
str = "type inference is $(whatItIs)!"
whatItIs
"#
Expand All @@ -342,7 +342,7 @@ mod solve_expr {
r#"
rec = { whatItIs: "great" }
str = "type inference is \(rec.whatItIs)!"
str = "type inference is $(rec.whatItIs)!"
rec
"#
Expand Down Expand Up @@ -4739,7 +4739,7 @@ mod solve_expr {
r#"
setRocEmail : _ -> { name: Str, email: Str }_
setRocEmail = \person ->
{ person & email: "\(person.name)@roclang.com" }
{ person & email: "$(person.name)@roclang.com" }
setRocEmail
"#
),
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/test_gen/src/gen_abilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ fn specialize_unique_newtype_records() {
main =
when Str.fromUtf8 (Encode.toBytes {a: Bool.true} TotallyNotJson.json) is
Ok s -> when Str.fromUtf8 (Encode.toBytes {b: Bool.true} TotallyNotJson.json) is
Ok t -> "\(s)\(t)"
Ok t -> "$(s)$(t)"
_ -> "<bad>"
_ -> "<bad>"
"#
Expand Down
6 changes: 3 additions & 3 deletions crates/compiler/test_gen/src/gen_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ fn list_map_try_ok() {
List.mapTry [1, 2, 3] \num ->
str = Num.toStr (num * 2)
Ok "\(str)!"
Ok "$(str)!"
"#,
// Result Str [] is unwrapped to just Str
RocList::<RocStr>::from_slice(&[
Expand Down Expand Up @@ -3738,10 +3738,10 @@ fn issue_3571_lowlevel_call_function_with_bool_lambda_set() {
List.concat state mappedVals
add2 : Str -> Str
add2 = \x -> "added \(x)"
add2 = \x -> "added $(x)"
mul2 : Str -> Str
mul2 = \x -> "multiplied \(x)"
mul2 = \x -> "multiplied $(x)"
foo = [add2, mul2]
bar = ["1", "2", "3", "4"]
Expand Down
20 changes: 10 additions & 10 deletions crates/compiler/test_gen/src/gen_primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3197,7 +3197,7 @@ fn recursively_build_effect() {
hi = "Hello"
name = "World"
"\(hi), \(name)!"
"$(hi), $(name)!"
main =
when nestHelp 4 is
Expand Down Expand Up @@ -3953,8 +3953,8 @@ fn compose_recursive_lambda_set_productive_toplevel() {
compose = \f, g -> \x -> g (f x)
identity = \x -> x
exclaim = \s -> "\(s)!"
whisper = \s -> "(\(s))"
exclaim = \s -> "$(s)!"
whisper = \s -> "($(s))"
main =
res: Str -> Str
Expand All @@ -3976,8 +3976,8 @@ fn compose_recursive_lambda_set_productive_nested() {
compose = \f, g -> \x -> g (f x)
identity = \x -> x
exclaim = \s -> "\(s)!"
whisper = \s -> "(\(s))"
exclaim = \s -> "$(s)!"
whisper = \s -> "($(s))"
res: Str -> Str
res = List.walk [ exclaim, whisper ] identity compose
Expand All @@ -3998,8 +3998,8 @@ fn compose_recursive_lambda_set_productive_inferred() {
compose = \f, g -> \x -> g (f x)
identity = \x -> x
exclaim = \s -> "\(s)!"
whisper = \s -> "(\(s))"
exclaim = \s -> "$(s)!"
whisper = \s -> "($(s))"
res = List.walk [ exclaim, whisper ] identity compose
res "hello"
Expand All @@ -4024,8 +4024,8 @@ fn compose_recursive_lambda_set_productive_nullable_wrapped() {
else \x -> f (g x)
identity = \x -> x
exclame = \s -> "\(s)!"
whisper = \s -> "(\(s))"
exclame = \s -> "$(s)!"
whisper = \s -> "($(s))"
main =
res: Str -> Str
Expand Down Expand Up @@ -4552,7 +4552,7 @@ fn reset_recursive_type_wraps_in_named_type() {
Cons x xs ->
strX = f x
strXs = printLinkedList xs f
"Cons \(strX) (\(strXs))"
"Cons $(strX) ($(strXs))"
"#
),
RocStr::from("Cons 2 (Cons 3 (Cons 4 (Nil)))"),
Expand Down
10 changes: 5 additions & 5 deletions crates/compiler/test_mono/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ fn lambda_capture_niches_with_other_lambda_capture() {
when val is
_ -> ""
capture2 = \val -> \{} -> "\(val)"
capture2 = \val -> \{} -> "$(val)"
x : [A, B, C]
x = A
Expand Down Expand Up @@ -1984,7 +1984,7 @@ fn polymorphic_expression_unification() {
]
parseFunction : Str -> RenderTree
parseFunction = \name ->
last = Indent [Text ".trace(\"\(name)\")" ]
last = Indent [Text ".trace(\"$(name)\")" ]
Indent [last]
values = parseFunction "interface_header"
Expand Down Expand Up @@ -2540,7 +2540,7 @@ fn recursively_build_effect() {
hi = "Hello"
name = "World"
"\(hi), \(name)!"
"$(hi), $(name)!"
main =
when nestHelp 4 is
Expand Down Expand Up @@ -2856,8 +2856,8 @@ fn compose_recursive_lambda_set_productive_nullable_wrapped() {
else \x -> f (g x)
identity = \x -> x
exclame = \s -> "\(s)!"
whisper = \s -> "(\(s))"
exclame = \s -> "$(s)!"
whisper = \s -> "($(s))"
main =
res: Str -> Str
Expand Down
6 changes: 3 additions & 3 deletions crates/glue/platform/Types.roc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ shape = \@Types types, id ->
Err OutOfBounds ->
idStr = Num.toStr (InternalTypeId.toNat id)

crash "TypeId #\(idStr) was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at <https://github.com/roc-lang/roc/issues>"
crash "TypeId #$(idStr) was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at <https://github.com/roc-lang/roc/issues>"

alignment : Types, TypeId -> U32
alignment = \@Types types, id ->
Expand All @@ -54,7 +54,7 @@ alignment = \@Types types, id ->
Err OutOfBounds ->
idStr = Num.toStr (InternalTypeId.toNat id)

crash "TypeId #\(idStr) was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at <https://github.com/roc-lang/roc/issues>"
crash "TypeId #$(idStr) was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at <https://github.com/roc-lang/roc/issues>"

size : Types, TypeId -> U32
size = \@Types types, id ->
Expand All @@ -63,4 +63,4 @@ size = \@Types types, id ->
Err OutOfBounds ->
idStr = Num.toStr (InternalTypeId.toNat id)

crash "TypeId #\(idStr) was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at <https://github.com/roc-lang/roc/issues>"
crash "TypeId #$(idStr) was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at <https://github.com/roc-lang/roc/issues>"
Loading

0 comments on commit b2b5587

Please sign in to comment.