Skip to content

Commit

Permalink
RFC: Prohibit use of interpolated strings in function calls without p…
Browse files Browse the repository at this point in the history
…arentheses (#648)

We've had this restriction in the original RFC, but decided to remove it afterwards. This change puts the restriction back - we need to work through some implications of future support for string-based DSLs together with interpolated strings which may or may not change the behavior here, for example to allow something like

```
local fragment = xml `
  <img src="{self.url}" />
`
```
  • Loading branch information
zeux authored Aug 25, 2022
1 parent b2f9f53 commit e84bccc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rfcs/syntax-string-interpolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ print(`Welcome to \
-- Luau!
```

This expression can also come after a `prefixexp`:
We currently *prohibit* using interpolated strings in function calls without parentheses, this is illegal:

```
local name = "world"
print`Hello {name}`
```

> Note: This restriction is likely temporary while we work through string interpolation DSLs, an ability to pass individual components of interpolated strings to a function.
The restriction on `{{` exists solely for the people coming from languages e.g. C#, Rust, or Python which uses `{{` to escape and get the character `{` at runtime. We're also rejecting this at parse time too, since the proper way to escape it is `\{`, so:

```lua
Expand Down

1 comment on commit e84bccc

@sebastiaan0000
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wat moet ik doen

Please sign in to comment.