cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 160 forks source link

Not handling valid Java "function" variable name #582

Closed rgladwell closed 3 years ago

rgladwell commented 4 years ago

Using the latest JSweet transpiler (2.3.7) getting compilation errors for valid Java a bit like this:

ERROR: identifier expected. 'function' is a reserved word that cannot be used here at itext7/kernel/src/main/java/com/itextpdf/kernel/pdf/function/PdfFunction.java(58)

With the following code:

            for (PdfFunction function : functions)
                array.add(function.getPdfObject());

Workaround: Renaming the variable name resolves this compilation issue.

Note: function is a reserved keyword in JavaScript.

lgrignon commented 4 years ago

Thanks for reporting, it will be fixed.

rgladwell commented 4 years ago

Thanks!

lgrignon commented 4 years ago

@renaudpawlak did you deploy a snapshot version?

lgrignon commented 4 years ago

Okay, just did it. 2.3.8-SNAPSHOT is up to date

rgladwell commented 4 years ago

I'm getting a similar error for this, despite the fact I think you did fix this. When I compile this file using the latest SNAPSHOT:

https://github.com/ink-elements/itext7-js/blob/master/itext7/kernel/src/main/java/com/itextpdf/kernel/pdf/function/PdfFunction.java

With the following error:

ERROR: identifier expected. 'function' is a reserved word that cannot be used here at itext7/kernel/src/main/java/com/itextpdf/kernel/pdf/function/PdfFunction.java(58)
ERROR: identifier expected at itext7/kernel/src/main/java/com/itextpdf/kernel/pdf/function/PdfFunction.java(58)

Not sure why?

lgrignon commented 3 years ago

Hello again @rgladwell 3.0.0-RC4 has been deployed (and maven plugin is up to date) if you want to give it a shot Warning : if you declare jsweet-core as a dependency, groupId is now <groupId>org.jsweet.v3</groupId>

I hope it will work for you 🤞

rgladwell commented 3 years ago

Thanks @lgrignon.

I can't seem to find the 3.0.0-RC4 dependency:

  <dependencies>
    <dependency>
      <groupId>org.jsweet.v3</groupId>
      <artifactId>jsweet-core</artifactId>
      <version>3.0.0-RC4</version>
    </dependency>
  </dependencies>

Which repo/dependency should I be using? Is the transpiler bundled in the core package now?

lgrignon commented 3 years ago

jsweet-transpiler is 3.0.0-RC4 jsweet-core is 6.0.0 (meaning it's es6+ api)

rgladwell commented 3 years ago

Trying:

  <dependencies>
    <dependency>
      <groupId>org.jsweet.v3</groupId>
      <artifactId>jsweet-transpiler</artifactId>
      <version>3.0.0-RC4</version>
    </dependency>
  </dependencies>

But it still won't resolve

lgrignon commented 3 years ago
<dependency>
      <groupId>org.jsweet</groupId>
      <artifactId>jsweet-transpiler</artifactId>
      <version>3.0.0-RC4</version>
    </dependency>

<dependency>
      <groupId>org.jsweet.v3</groupId>
      <artifactId>jsweet-core</artifactId>
      <version>6.0.0</version>
    </dependency>

sorry for the (temporary) inconvenience

rgladwell commented 3 years ago

Thanks, this seemed to fix this issue.

rgladwell commented 3 years ago

Unfortunately, there is a further error:

https://github.com/cincheo/jsweet/issues/624

lgrignon commented 3 years ago

I close this one, we will focus on https://github.com/cincheo/jsweet/issues/624