-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String interpolation new #729
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8fc23a5
Fix bug with escaped squiglies at the end of strigs
Licenser e932ccb
Remove unused unsafe impls
Licenser 3e013b4
Implement new escape sequence
Licenser 637ac0a
Fix CI update
Licenser b9a481b
Fix integration tests
Licenser bfbe61b
Improve errors for #{}
Licenser 31cb0bc
Improve handling of recursion errors
Licenser 7a59a06
Exclude accessors
Licenser 9982263
Add missing test
Licenser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
tests/script_errors/heredoc_interpolation_extractor/error.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Error: | ||
1 | let heredoc = """ | ||
2 | { | } | ||
| ^^^ It looks like you forgot to terminate an extractor with a closing '|' | ||
2 | #{ | } | ||
| ^^^ It looks like you forgot to terminate an extractor with a closing '|' |
2 changes: 1 addition & 1 deletion
2
tests/script_errors/heredoc_interpolation_extractor/script.tremor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
let heredoc = """ | ||
{ | } | ||
#{ | } | ||
"""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Error: | ||
1 | """ | ||
2 | before { `ident unfinished } after | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ It looks like you forgot to terminate an ident with a closing '`' | ||
2 | before #{ `ident unfinished } after | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ It looks like you forgot to terminate an ident with a closing '`' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
""" | ||
before { `ident unfinished } after | ||
before #{ `ident unfinished } after | ||
""" |
4 changes: 2 additions & 2 deletions
4
tests/script_errors/heredoc_interpolation_multiline/error.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Error: | ||
1 | """ | ||
2 | { " | ||
| ^ It looks like you forgot to terminate a string with a closing '"' | ||
2 | #{ " | ||
| ^ It looks like you forgot to terminate a string with a closing '"' |
2 changes: 1 addition & 1 deletion
2
tests/script_errors/heredoc_interpolation_multiline/script.tremor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
""" | ||
{ " | ||
#{ " | ||
|
||
} | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Error: | ||
1 | """ | ||
2 | { | ||
| ^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '{' ? Escape it as '\{' or '{{'. | ||
2 | #{ | ||
| ^^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '#{'? Escape it as '\#{'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
""" | ||
{ | ||
#{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Error: | ||
1 | """ | ||
2 | {""" | ||
| ^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '{' ? Escape it as '\{' or '{{'. | ||
2 | #{""" | ||
| ^^^^^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '#{'? Escape it as '\#{'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
""" | ||
{""" | ||
#{""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Error: | ||
2 | let x = """ | ||
3 | {"""; | ||
| ^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '{' ? Escape it as '\{' or '{{'. | ||
3 | #{"""; | ||
| ^^^^^^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '#{'? Escape it as '\#{'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
use std::string; | ||
let x = """ | ||
{"""; | ||
#{"""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Error: | ||
1 | "{" | ||
| ^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '{' ? Escape it as '\{' or '{{'. | ||
1 | "#{" | ||
| ^^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '#{'? Escape it as '\#{'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"{" | ||
"#{" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Error: | ||
1 | let x = "before { { {}"; | ||
| ^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '{' ? Escape it as '\{' or '{{'. | ||
1 | let x = "before #{ { {}"; | ||
| ^^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '#{'? Escape it as '\#{'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
let x = "before { { {}"; | ||
let x = "before #{ { {}"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Error: | ||
1 | use std::string; | ||
2 | let e = "\u0065 { `unterminated_ident } \u0076 {2} \u0080"; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It looks like you forgot to terminate an ident with a closing '`' | ||
2 | let e = "\u0065 #{ `unterminated_ident } \u0076 #{2} \u0080"; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It looks like you forgot to terminate an ident with a closing '`' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
use std::string; | ||
let e = "\u0065 { `unterminated_ident } \u0076 {2} \u0080"; | ||
let e = "\u0065 #{ `unterminated_ident } \u0076 #{2} \u0080"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Error: | ||
1 | "#{}" | ||
| ^^^ You have an interpolation without content. | ||
| NOTE: Did you mean to write a literal '#{'? Escape it as '\#{'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"#{}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Error: | ||
1 | let si = "before { | ||
| ^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '{' ? Escape it as '\{' or '{{'. | ||
1 | let si = "before #{ | ||
| ^^ It looks like you forgot to terminate a string interpolation with a closing '}' | ||
| NOTE: Did you mean to write a literal '#{'? Escape it as '\#{'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
let si = "before { | ||
let si = "before #{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Error: | ||
1 | let escape = " { "\z" } "; | ||
| ^^ An unexpected escape code 'z' was found | ||
1 | let escape = " #{ "\z" } "; | ||
| ^^ An unexpected escape code 'z' was found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
let escape = " { "\z" } "; | ||
let escape = " #{ "\z" } "; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Error: | ||
1 | " { | } " | ||
| ^^^^^ It looks like you forgot to terminate an extractor with a closing '|' | ||
1 | " #{ | } " | ||
| ^^^^^ It looks like you forgot to terminate an extractor with a closing '|' |
2 changes: 1 addition & 1 deletion
2
tests/script_errors/string_interpolation_extractor/script.tremor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
" { | } " | ||
" #{ | } " |
4 changes: 2 additions & 2 deletions
4
tests/script_errors/string_interpolation_invalid_utf8/error.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Error: | ||
1 | " { " \u666G " } " | ||
| ^^^^^^ An invalid UTF8 escape sequence was found | ||
1 | " #{ " \u666G " } " | ||
| ^^^^^^ An invalid UTF8 escape sequence was found |
2 changes: 1 addition & 1 deletion
2
tests/script_errors/string_interpolation_invalid_utf8/script.tremor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
" { " \u666G " } " | ||
" #{ " \u666G " } " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Error: | ||
2 | | ||
3 | let a = 7; | ||
4 | record::from_array(a) | ||
| ^^^^^^^^^^^^^^^^^^^^^ Bad type passed to function record::from_array/1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Error: | ||
1 | use std::math; | ||
2 | let a = 7; | ||
3 | math::max("snot", a) | ||
| ^^^^^^^^^^^^^^^^^^^^ Bad type passed to function math::max/2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Error: | ||
1 | use std::string; | ||
2 | let a = 7; | ||
3 | string::format(a, "snot", "badger") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Runtime error in function string::format/3: expected 1st parameter to format to be a format specifier e.g. to print a number use `string::format("{}", 1)` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Runtime error in function string::format/3: expected 1st parameter to format to be a format specifier e.g. to print a number use `string::format("{}", 1)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Error: | ||
1 | use std::string; | ||
2 | let a = 7; | ||
3 | string::format(a, "snot", "badger", "cake") | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Runtime error in function string::format/4: expected 1st parameter to format to be a format specifier e.g. to print a number use `string::format("{}", 1)` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Runtime error in function string::format/4: expected 1st parameter to format to be a format specifier e.g. to print a number use `string::format("{}", 1)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Error: | ||
4 | end; | ||
5 | | ||
6 | boom(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💥 |
||
| ^^^^^^^ Recursion limit Reached |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn boom(x) with | ||
let x = x + 1; | ||
recur(x) | ||
end; | ||
|
||
boom(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const a = "snot"; | ||
const b = ( a + " badger" ); | ||
|
||
"{b}: {event}!" | ||
"#{b}: #{event}!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
mod b with | ||
fn snot(n) with | ||
"cake {n}" | ||
"cake #{n}" | ||
end; | ||
end; | ||
|
||
mod a with | ||
mod b with | ||
fn snot(n) with "snot {n}" end | ||
fn snot(n) with "snot #{n}" end | ||
end; | ||
fn badger(n) with "{b::snot(n)} badger {n}" end | ||
fn badger(n) with "#{b::snot(n)} badger #{n}" end | ||
end; | ||
|
||
[a::badger(event), b::snot(event)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
mod a with | ||
mod b with | ||
fn snot(n) with "snot {n}" end | ||
fn snot(n) with "snot #{n}" end | ||
end; | ||
fn badger(n) with "{b::snot(n)} badger {n}" end | ||
fn badger(n) with "#{b::snot(n)} badger #{n}" end | ||
end; | ||
|
||
a::badger(event) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😻