nauti
nauti

Reputation: 1436

thrift js:node - Cannot use reserved language keyword: "not"

When converting a thrift object for nodejs:

thrift -r --gen js:node state_service.thrift

The following error is thrown:

[ERROR: /state_service.thrift:33] (last token was 'not') Cannot use reserved language keyword: "not"

The lines in the code around 33 are:

typedef bool Not
struct Exp {
  1: string left
  2: Not not
  3: BinaryOp op
  4: AnyValue right
}

I am using the most recent Thrift version 0.9.2

Upvotes: 4

Views: 2009

Answers (2)

BarT
BarT

Reputation: 347

Try to change the not to something else, i think the problem is that 'not' may have another meaning in the language that you choose to generate.

2: Not not

Upvotes: 1

JensG
JensG

Reputation: 13411

The solution is to not use the reserved language keyword, as advised by the Thrift compiler. These keywords are reserved for a reason. Thrift is a cross-language tool, and not is indeed a keyword in some of them.

I don't want to change the processing code only because of a faulty js converter.

I beg to differ. Faulty is something that does not work, altough it should. Thrift clearly tells you that what you are about to try is illegal (as of today) and what the problem is.

To put it another way: With Linux, you can put uppercase and lowercase letters in a file name (actually you can put a whole bunch of strange things in, but I'll make it easy). So creating a FILE and a file in the same folder will work perfectly. If you now take your program and run it on Windows, relying on that behaviour, you will sooner or later run into trouble and may start to complain you "dont want to change your processing code only because of that faulty OS".

Note that complaining will not help you out of the pothole, altough the endorphines emitted during that process will make sure you have a fun time. The solution is of course to wait until Microsoft fixed their faulty OS, because you make the rules. Correct?

Of course not. So if you feel the implementation is wrong - fine! This is Open Source, and nobody claimed perfection. You are free to provide a patch, and we will happily review it. But please make sure you tested it with all 20+ languages currently supported by Thrift.

Upvotes: 0

Related Questions