Closed keithphw closed 4 years ago
Hello @keithphw Thanks for reporting! JSweet uses TypeScript compilation which indeed does not allow unreachable code. It could be an option (using this) but it is a side case, I am not sure it would be high priority. What do you think @renaudpawlak ?
Thanks for your reply, that's interesting! I 100% respect your decision and would hate for this issue to sap your valuable time making other features or squishing more important bugs. But for me this error seems quite important because such failures are a total mystery for Java developers such as myself who know nothing about Typescript (and JavaScript) so it makes JSweet appear unreliable and buggy. While the error is reported in the transpilation step, it's difficult to recognise it in the Java code since the Java IDE doesn't highlight it and the error is one amongst a large number of other warnings in the maven output. Best wishes, Keith
I understand, I will take a look soon. Please note that we are open to contributions if you are willing to help :)
That's weird, I wrote a sample test case, and cannot reproduce: https://github.com/cincheo/jsweet/commit/912f4ba9cbc837358e25b119045dbeec7c86548c
This unit test passes
Which version of Java / Maven / JSweet are you using?
Hi, I'm using: maven version: 3.6.3 [INFO] JSweet transpiler version 3.0.0-SNAPSHOT (build date: 2019-12-08 16:26:22) The if statement code that you posted causes the error for me if I put it in my program's main method. Strange that the error doesn't show up for you. EDIT: My Maven POM says:
Yeah, actually it's not because this commit is on a JSweet 2 branch. I will merge and try on JSweet 3 (I guess this is just working with JSweet 2)
Hum, can't reproduce on JSweet 3 either. Could you please try again with JSweet 3.0 RC2 and send me a small repro (zip or GitHub repo), thanks
I'm not sure how to change to 3.0 RC2 I'm sorry.
I changed my pom.xml to say:
<jsweet.transpiler.version>3.0.0-RC2/</jsweet.transpiler.version>
rather than the quickstart default of
<jsweet.transpiler.version>3.0.0-SNAPSHOT</jsweet.transpiler.version>
But the new version failed with lots of errors:
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.k:3.0.0-RC2/ (C:\...\pom.xml) has 1 error
[ERROR] 'build.plugins.plugin.version' for org.jsweet:jsweet-maven-plugin must not contain any of these characters \/:"<>|?* but found / @ ...
Let me check on the quickstart
Hum, this one might be on your side. It "works on my machine" ^^ and on GitHub https://github.com/cincheo/jsweet-quickstart/runs/560328736?check_suite_focus=true
Thank you for the specific instructions. After that change to RC2, it no longer fails! Fantastic! Thank you very much
Well, that's very good news. I am glad and close this ticket. Enjoy using JSweet
Hi, I was porting a java project to JSweet and met a JSweet transpilation error, despite the Netbeans IDE editor not showing any errors in the java code. By trial and error I discovered that the problem was unreachable code which creates an error in JSweet transpilation, leading to a failure. This code caused the error:
Here is the error and transpilation failure reported:
Of course unreachable statements are a bit silly, but they're useful as a switch for running different code during development testing. javac doesn't fail compilation when it finds unreachable statements so I don't think JSweet should either.
I suspect that this potential bug may be the cause of other mystery bugs such as: https://github.com/cincheo/jsweet/issues/147 Cheers, Keith
PS: Thank you for this fantastic project.