Some documentation language adjustments & improved error messages

pull/8513/head
Laurin-Luis Lehning 4 years ago committed by Xavier Claessens
parent 71e9909ffd
commit f7dd111333
  1. 10
      docs/markdown/Syntax.md
  2. 2
      docs/markdown/snippets/fstrings.md
  3. 3
      mesonbuild/interpreterbase.py
  4. 2
      test cases/failing/113 invalid fstring/test.json

@ -198,7 +198,15 @@ s = f'int: @n@, string: @m@'
```
Currently only identity-expressions are supported inside of format
strings.
strings, meaning you cannot use arbitrary Meson expressions inside of them.
```meson
n = 10
m = 5
# The following is not a valid format string
s = f'result: @n + m@'
```
### String methods

@ -1,7 +1,7 @@
## Introducing format strings to the Meson language
In addition to the conventional `'A string @0@ to be formatted @1@'.format(n, m)`
method of formatting strings in the Meson DSL, there's now the additional
method of formatting strings in the Meson language, there's now the additional
`f'A string @n@ to be formatted @m@'` notation that provides a non-positional
and clearer alternative. Meson's format strings are currently restricted to
identity-expressions, meaning `f'format @'m' + 'e'@'` will not parse.

@ -937,7 +937,8 @@ The result of this is undefined and will become a hard error in a future Meson r
try:
val = self.variables[var]
if not isinstance(val, (str, int, float, bool)):
raise InvalidCode(f'Identifier "{var}" does not name a formattable variable.')
raise InvalidCode(f'Identifier "{var}" does not name a formattable variable ' +
'(has to be an integer, a string, a floating point number or a boolean).')
return str(val)
except KeyError:

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/113 invalid fstring/meson.build:4:0: ERROR: Identifier \"dict\" does not name a formattable variable."
"line": "test cases/failing/113 invalid fstring/meson.build:4:0: ERROR: Identifier \"dict\" does not name a formattable variable (has to be an integer, a string, a floating point number or a boolean)."
}
]
}

Loading…
Cancel
Save