[
https://issues.apache.org/jira/browse/THRIFT-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13017751#comment-13017751
]
Nevo Hed commented on THRIFT-1130:
----------------------------------
This was my concern too, and my threshold for passage was to ensure that it
will provide an error, obviously its not the same error as it originally
did.
At the end of the day, this seems to be pretty much like a c-pre-processor
macros:
#define true 1
#define false 0
The the items NOT in my negative tests that WOULD fail are attempts to use
true/false as field numbers (for example)
What you are asking for is a negative test (which I performed locally), I
only saw one but it is commented out (so its not in any automated test)
Is this how you would like to see it? If not can you point me at an example
of a negative test in ThriftTest.thrift?
This is what I tried and what I had in mind ...
struct boolDefValTst {
// positive tests:
1: optional bool myBool_1 = true,
2: optional bool myBool_2 = false,
3: optional bool myBool_3 = 1,
4: optional bool myBool_4 = 0,
5: optional bool myBool_5,
6: optional i32 myI32_1 = true,
// negative tests:
// (uncomment each, one at a time to test)
// - Test that we get an error using boolean constants as field names
//7: optional i32 true, // [ERROR:...] (last token was 'true')
syntax error
//8: optional i32 false, // [ERROR:...] (last token was 'false')
syntax error
// - Test that we get an error using boolean constants type names
//9: optional true myI32_2, // [ERROR:...] (last token was 'true')
syntax error
//10: optional false myI32_3, // [ERROR:...] (last token was 'false')
syntax error
// - Test that we get an error using boolean constants as values for
incompatible types
//11: optional string myStr1 = true, // [FAILURE:...] type error:
const "myStr" was declared as string
}
Thanks
> Add the ability to specify symbolic default value for optional boolean
> ----------------------------------------------------------------------
>
> Key: THRIFT-1130
> URL: https://issues.apache.org/jira/browse/THRIFT-1130
> Project: Thrift
> Issue Type: Improvement
> Components: Compiler (General)
> Affects Versions: 0.5, 0.6
> Reporter: Nevo Hed
> Priority: Minor
> Attachments: bool.patch
>
>
> When specifying a default value for an optional struct member of the type
> bool the user now needs to enter a numeric value (0, or 1). It would be nice
> if they could specify a symbolic value such as 'true' & 'false'
> Example thrift file:
> struct AtscStrmRecordRequestT {
> 1: optional bool bDoSomething = true,
> 2: required string whatever;
> }
> With current error
> {quote}
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
> {quote}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira