Jens-G opened a new pull request, #3842: URL: https://github.com/apache/thrift/pull/3842
Follow-up to #3786. The string literal syntax was not documented anywhere. Rule [36] in `doc/specs/idl.md`, which is also what https://thrift.apache.org/docs/idl shows, defined Literal ::= ('"' [^"]* '"') | ("'" [^']* "'") Read literally, a backslash is an ordinary character, a double quote cannot appear in a double-quoted literal and line breaks are allowed. None of that matches the compiler, and it is the reading the THRIFT-4244 report was based on. ## Changes - `doc/specs/idl.md`: rule [36] now allows escape sequences, a new rule [37] `Escape` lists the six the lexer accepts (`\"` `\'` `\\` `\n` `\r` `\t`), and one sentence covers line breaks and unknown escapes. The rules after it are renumbered; nothing refers to their numbers. - `tutorial/tutorial.thrift`: describes the same syntax next to `MAPCONSTANT`. It is a plain `/* */` comment rather than a `/** */` doc comment, so the text never reaches generated code. The tutorial deliberately gets no real constant with escapes: several generators do not escape string constants correctly for their language, and such a constant would break the rs and c_glib tutorial builds, for example. That is tracked in [THRIFT-6236](https://issues.apache.org/jira/browse/THRIFT-6236). ## Verification Against a compiler built from current master (81103bf9c): - Every statement in the tutorial comment was checked, including the negative ones, with values read back from generated Python. `\T` (in both quote styles), `\x`, `\u`, `\0` and `\ ` are rejected, and so is a line break, in both quote styles and right after a backslash. `include "d\\x/incd.thrift"` resolves a file in a directory named `d\x` (the same include with a missing directory fails), and annotation values follow the same rules. - `tutorial.thrift` was generated with all 29 generators plus the option variants the tutorial builds use (`go:thrift_import=…`, `js:node`, `js:ts`, `js:node,ts`, `php:server`, `py:tornado`, `py:twisted`). All 279 files and the compiler output are byte-identical before and after. As a positive control, changing the text of the enum doc comment changes 21 of those files. - `thrift -strict -v` reports the same warnings before and after; one line number shifts by the 19 inserted lines. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
