[ 
https://issues.apache.org/jira/browse/THRIFT-5690?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17698087#comment-17698087
 ] 

Jens Geyer edited comment on THRIFT-5690 at 3/8/23 9:48 PM:
------------------------------------------------------------

Funny. Just tested all from 0.9.1  onwards and can confirm your observation. 
0.9.1 shows that message, 0.9.2 until 0.16.0 do not.

{code}
struct Test {
10: optional Foo foo = \{"bar":42};
}

struct Foo {
10: optional string bar;
}
{code}

No error with 0.16.0 but in fact generates incorrect code w/o complaint (bar is 
a string not an int). This is because the "forward" type type is not resolved 
at all and thus essentially bypasses all validation silently. Changing the 
order of the structs produces the expected error message

{code}
[FAILURE:test.thrift:6] type error: const "foo.bar" was declared as string
{code}

The "_the "forward" type type is not resolved at all_" part of the issue was 
resolved during THRIFT-5540 which as a consequence made that case obvious again.


was (Author: jensg):
Funny. Just tested all from 0.9.1  onwards and can confirm your observation. 
0.9.1 shows that message, 0.9.2 until 0.16.0 do not.



{code}

struct Test {
10: optional Foo foo = \{"bar":42};
}

struct Foo {
10: optional string bar;
}

{code}

No error with 0.16.0 but in fact generates incorrect code w/o complaint (bar is 
a string not an int). This is because the "forward" type type is not resolved 
at all and thus essentially bypasses all validation silently. Changing the 
order of the structs produces the expected error message

{code}
[FAILURE:test.thrift:6] type error: const "foo.bar" was declared as string
{code}

> Constant expects type to be defined before
> ------------------------------------------
>
>                 Key: THRIFT-5690
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5690
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (General)
>            Reporter: Bogdan Drutu
>            Assignee: Jens Geyer
>            Priority: Major
>             Fix For: 0.19.0
>
>
> {code}
> struct Test {
> 10: optional Foo foo = {};
> }
> struct Foo {
> 10: optional string bar;
> }
> {code}
> Tried with thrift 0.18.0/0.18.1
> {code}
> [ERROR] thrift failed output: Type "Foo" not defined
> {code} 
> Best guess can be related with 
> https://issues.apache.org/jira/browse/THRIFT-5626



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

Reply via email to