cincheo / jsweet

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

if then else bug #33

Closed ssatguru closed 8 years ago

ssatguru commented 8 years ago

following

package org.ssatguru.babylonjs;
import static jsweet.dom.Globals.console;
public class CodeSnippet {
    public static void main(String args[]){
        int i =1;
        if (i==1)console.log("is true");
        else console.log("is false");
    }
}

gives following error during TS compile

[INFO] JSweet transpiler version 1.0.0-SNAPSHOT (build date: 2016-01-16 10:30:13)
ERROR: ';' expected. at org\ssatguru\babylonjs\CodeSnippet.ts(6)
[ERROR] transpilation failed
renaudpawlak commented 8 years ago

Thank you for this one (good one). There is a lack of support for statements with optional blocks.

Temporary workaround: use blocks.

    if (i==1) { console.log("is true"); }
    else { console.log("is false"); }

I should be committing a fix very soon though.

renaudpawlak commented 8 years ago

It should be fixed with some variations (see https://github.com/cincheo/jsweet/blob/master/src/test/java/source/syntax/StatementsWithNoBlocks.java)

ssatguru commented 8 years ago

Great, Thanks