diff options
| author | Carl Åstholm <carl@astholm.se> | 2024-02-13 18:30:22 +0100 |
|---|---|---|
| committer | Carl Åstholm <carl@astholm.se> | 2024-04-07 14:47:10 +0200 |
| commit | d8e7eda5f4a894fe8fec8c53f7bcc3d475dd55c9 (patch) | |
| tree | cb194249a7cdc1643283219bc6c327ad5b8363ac /src | |
| parent | 129de47a71b954b1118ce188f7032ad726491f53 (diff) | |
| download | zig-d8e7eda5f4a894fe8fec8c53f7bcc3d475dd55c9.tar.gz zig-d8e7eda5f4a894fe8fec8c53f7bcc3d475dd55c9.zip | |
std.zig.fmtId: conditionally escape primitives/`_`
This is a breaking change.
This updates `std.zig.fmtId` to support conditionally escaping
primitives and the reserved `_` identifier via format specifiers:
- `{}`: escape invalid identifiers, identifiers that shadow primitives
and the reserved `_` identifier.
- `{p}`: same as `{}`, but don't escape identifiers that
shadow primitives.
- `{_}`: same as `{}`, but don't escape the reserved `_` identifier.
- `{p_}` or `{_p}`: only escape invalid identifiers.
(The idea is that `p`/`_` mean "allow primitives/underscores".)
Any other format specifiers will result in compile errors.
Additionally, `isValidId` now considers `_` a valid identifier. If this
distinction is important, consider combining existing uses of this
function with the new `isUnderscore` function.
Diffstat (limited to 'src')
0 files changed, 0 insertions, 0 deletions
