v: refactor $var to ${var} across entire repository#26494
v: refactor $var to ${var} across entire repository#26494spytheman merged 4 commits intovlang:masterfrom
Conversation
… android_cross_compile.vsh Part of vlang#26382
String interpolation has two supported variants as of today. '$var' and '${var}', with '${var}' being preferred.
Refactoring all occurrences to the new format is a step in entirely removing the interpolation support for '$var'.
scanner.v has not been altered, a follow-up commit that actually removes support for $var can do the final work in rephrasing comments and such.
|
If I understand the To: |
|
There is also other output that is misaligned, for example the I should run |
No, this is incorrect. There are no variables by those names, and no |
|
I'll consolidate the errors in this one message.
I have mistakenly changed the error message from My guess is that it's because ast.StringInterLiteral uses a fn (mut c Checker) prefix_expr(mut node ast.PrefixExpr) ast.Type {
// ...
if node.op == .amp && (!right_is_ptr || (right_is_ptr && expr is ast.CallExpr)) {
if expr in [ast.BoolLiteral, ast.CallExpr, ast.CharLiteral, ast.FloatLiteral, ast.IntegerLiteral,
ast.InfixExpr, ast.StringLiteral, ast.StringInterLiteral] {
c.error('cannot take the address of ${expr}', node.pos)
}
// ...
}
}
I was going to write out all of the tests, but I would just be repeating myself. Should I change all my |
|
|
Removes `needs_braces` from get_fspec_braces and renames method to `get_fspec`
In an effort to completely deprecate interpolation without curly braces, the .str() method of a string literal will now always output with braces, for example `${name}` instead of `$name`
|
I am very pleased to say that I consider this pull request ready for proper review after CI has finished. In the commit "ast: always output string literals with braces", I took the liberty to refactor |
String interpolation has two supported variants as of today.
$varand${var}, with${var}being preferred.vfmt automatically converts
$varto${var}, but only for code that runs. Comments, .vsh files and test artifacts such as.vv,.outand such are unaffected. Refactoring all occurrences to the new format is a step in entirely removing the interpolation support for$var.scanner.v has not been altered, a follow-up commit that actually removes support for
$varcan do the final work in rephrasing comments and such.Other notes: