GithubHelp home page GithubHelp logo

Comments (5)

benjamin-bader avatar benjamin-bader commented on May 22, 2024 1

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.

benjamin-bader avatar benjamin-bader commented on May 22, 2024

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.

yfrancis avatar yfrancis commented on May 22, 2024

@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.

benjamin-bader avatar benjamin-bader commented on May 22, 2024

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.

benjamin-bader avatar benjamin-bader commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.