-
-
Notifications
You must be signed in to change notification settings - Fork 671
Can't use nullable strings in template literal #2918
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
Comments
How do we want this to actually behave? I can see a two options:
If we do allow them, we could choose to emit |
I'd go with emitting |
If string is nullable, it should be a compiler error similar for concat nullable plus non-nullable |
I think this is a bit different, since template literals support interpolating numbers, arrays, and other non-string objects, so other QoL features like emitting |
It maybe |
Making users have to adjust their own Luckily, JavaScript doesn't allow you to do @MaxGraey Does this make sense? |
I think a wrapper is needed when we emit |
I agree, since only template literals use that function anyway. Essentially we need to emit |
We basically compile nullable strings down to a ternary: `expr ? expr.toString() : "null"` Fixes AssemblyScript#2918.
Uh oh!
There was an error while loading. Please reload this page.
Bug description
Template literal strings can interpolate most scalar value types, including strings, numbers, booleans, etc.
However, trying to use a nullable string in a template literal currently leads to a compiler error.
Steps to reproduce
The error is confusing, as it doesn't explain why there's an incompatibility, and there's only one value the user is putting in the template literal.
AssemblyScript version
v0.27.36
The text was updated successfully, but these errors were encountered: