Comments (5)
Just confirmed my reading using the Apache compiler:
a.thrift:
namespace java a
enum Foo {
One
}
b.thrift:
namespace java b
struct Bar {
1: required a.Foo foo = One
}
$ thrift -gen java b.thrift
> [FAILURE:/Users/bendb/Development/thrift/b.thrift:6] error: identifier One is unqualified!
I'll have a fix for the initial bug, but don't want to deviate from Apache's behavior more than necessary; we'll match this validation behavior.
from thrifty.
Interesting. My understanding of the IDL spec is that one is required to use the fully-qualified name of imported type; from my perspective, this is working as intended. I would expect the following to work:
1: required testing_foo.Foo foo = testing_foo.Foo.One;
Is this behavior different from that of the Apache compiler?
from thrifty.
@benjamin-bader the fully qualified name is used for the field type, the Apache compiler accepts multiple forms:
required testing_foo.Foo foo = testing_foo.Foo.One
required testing_foo.Foo foo = Foo.One
required testing_foo.Foo foo = One
required testing_foo.Foo foo = 1
Whats interesting is that thrifty links all of these correctly - the type is resolved to the imported enum, its just the constant validation that fails because it does linker.lookupSymbol("Foo")
rather than linker.lookupSymbol("testing_foo.Foo")
.
From our investigation, the symbol testing_foo.Foo
is available at the field level, but when validation is performed on the constant value itself, this information is not passed through.
from thrifty.
Thanks @yfrancis, that's really helpful!
Thrift's inconsistencies are going to be the death of me. I'll have a fix soon.
from thrifty.
OK, I've finally got some time to address this. As I'm looking over the Apache compiler, it certainly appears that unqualified enum references in constants (e.g. required testing_foo.Foo foo = One
) are not accepted; this is as of version 0.9.3. What version are you using that allows this?
t_const_value.h
is approximately the same things as Thrifty's ConstValueElement
, and defines accessors used during const validation. The ones relevant to enums throw exceptions (i.e. fail) during const validation: https://github.com/apache/thrift/blob/0.9.3/compiler/cpp/src/parse/t_const_value.h#L107
How was this working for you previously?
from thrifty.
Related Issues (20)
- Get thrifty-runtime publishing properly
- Struct-valued constants are not yet implemented HOT 5
- Deprecated Gradle APIs in use, will break in Gradle 8 HOT 1
- Add Java codegen for struct-valued constants
- Question/feature request: Add header/comments to each file HOT 4
- This repo is missing important files
- Using thrifty-plugins with the thrifty gradle plugin HOT 9
- Add gradle-plugin API for TypeProcessor plugins
- Cyclical references in struct-valued constants? HOT 4
- Expose referenced Constants
- Schema should sort constants in dependency order
- Const refs list should be `distinct()`
- Support comments for struct properties HOT 2
- iOS support
- Gradle plugin ignores FieldNameStyle specification for Kotlin code gen HOT 1
- Fork! HOT 2
- Support iOS Simulator Arm64 Target
- [email protected] HOT 1
- BinaryProtocol hard-codes strict read/write properties
- What happened to the DecoratingProtocol? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thrifty.