sri96 / nila

Nila is a small Ruby inspired language to fix Javascript
https://github.com/sri96/nila
1 stars 0 forks source link

Automatic Return Doesn't Work With If Statements #16

Open adhithyan15 opened 10 years ago

adhithyan15 commented 10 years ago

Automatic return statement has erratic behavior when it comes to If..Else statement. Here is an example of what I mean

The following code doesn't produce correct results

def grade(student)

 if student.excellentWork

   val = "A"

 elsif student.okayStuff

   val = "B"

 else

   val = "C"

 end

end

The output is

grade = function(student) {

var return val, val;

if (student.excellentWork) {
  val = "A";
} else if (student.okayStuff) {
  val = "B";
} else {
 return val = "C";
}

end;
adhithyan15 commented 10 years ago

There are multiple things that are wrong with the produced code. So this issue will be fixed asap!

Update: We are developing a comprehensive solution for the bug. So we will postpone fixing the bug until 0.0.5.0.0. So this bug won't be fixed in the upcoming release. But other surrounding problems with the above code have been rectified.