slachiewicz opened a new pull request, #3925:
URL: https://github.com/apache/thrift/pull/3925

   `t_typedef::get_type()` resolved a forward typedef on first use, from inside 
whichever generator asked first, and on a target that was never declared it 
printed `Type "X" not defined` to stdout and called `exit(1)`: files the 
earlier generators had written stayed on disk (`thrift --gen go --gen java` 
left `GoUnusedProtection__.go`), the message carried no file or line, and a 
generator that never asked did not report it at all. 
https://issues.apache.org/jira/browse/THRIFT-6333
   
   `get_type()` now throws the message, and `parse()` resolves every type the 
program refers to — typedef chains, struct fields, constants, service 
signatures, through containers — before returning, so the error reaches 
`failure()` as `[FAILURE:file:line] Type "X" not defined` on stderr before any 
generator runs. `generate()` already catches the same exception for anything a 
generator asks for later. The line is the one the parser is at when the pass 
ends (the file's last line plus one), since the parse tree keeps no line per 
declaration; the file is the useful part.
   
   Behaviour changes: none for an input the compiler accepts (over every 
`.thrift` in the repository with `--gen go --gen java --gen json -r`: 159 files 
byte-identical, 35 rejected by both with the same status). `--audit` now 
rejects an undefined type it used to ignore; `test/audit/thrift_audit_test.pl` 
still passes all 46 cases.
   
   Tests: `compiler/cpp/tests/cpp/t_cpp_parser_typedef_tests.cc` checks that an 
undefined target throws the message and that a typedef declared after its use 
resolves.
   
   - [x] JIRA ticket: THRIFT-6333
   - [x] Title follows `THRIFT-NNNN:` pattern
   - [x] Single commit
   - [x] No breaking change
   


-- 
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]

Reply via email to