Sylwester Lachiewicz created THRIFT-6333:
--------------------------------------------

             Summary: An undefined typedef target is reported from inside a 
generator, after files were written
                 Key: THRIFT-6333
                 URL: https://issues.apache.org/jira/browse/THRIFT-6333
             Project: Thrift
          Issue Type: Bug
          Components: Compiler (General)
    Affects Versions: 0.22.0, 0.25.0, 0.24.0, 0.23.0
            Reporter: Sylwester Lachiewicz


A typedef whose target is never declared is not reported by the front end. 
{{t_typedef::get_type()}} ({{compiler/cpp/src/thrift/parse/t_typedef.cc}}) 
resolves the target lazily, on the first call, which happens inside whichever 
generator asks first, and on failure it prints to stdout and calls {{exit(1)}}:
{code}
typedef Missing T
struct S { 1: T t }
{code}
{noformat}
$ thrift -out out --gen go --gen java undefined_typedef.thrift; echo exit=$?
Type "Missing" not defined
exit=1
$ find out -type f
out/undefined_typedef/GoUnusedProtection__.go
{noformat}
Three consequences:
* The compiler exits from inside a generator, after output files may have been 
written ({{GoUnusedProtection__.go}} above); with several {{--gen}} arguments 
the earlier generators' files are on disk and the later ones are missing.
* The message goes to stdout, without the {{[FAILURE:file:line]}} prefix every 
other front-end error carries, and bypasses {{failure()}}.
* Whether the error is reported at all depends on the generator: one that never 
asks for the typedef's target (a documentation generator that only prints the 
symbolic name) succeeds on the same input.

Fix: resolve every typedef at the end of {{parse()}} in {{main.cc}}, so the 
error surfaces before any generator runs, and report it through {{failure()}} 
so it reaches stderr with the file and line like the other front-end errors. 
The message text stays {{Type "Missing" not defined}}. No output changes for 
any input the compiler accepts.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to