Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No break or return statement found in case #353

Open
notslang opened this issue Feb 18, 2015 · 9 comments
Open

No break or return statement found in case #353

notslang opened this issue Feb 18, 2015 · 9 comments

Comments

@notslang
Copy link

notslang commented Feb 18, 2015

function foobar() {
  switch (y) {
    case "one":
      if (x == 'foo') {
        return 'bar';
      } else {
        return 'foo';
      }
  }
}
function foobar() {
  switch (y) {
    case "one":
      throw new Error();
  }
}

Both of these examples fail because it doesn't detect the return in the if statement, or the throw that would end the function.

This pattern may seem kinda weird/contrived, but it's actually used in real code: https://github.com/pouchdb/GQL/blob/0b8d892d4922df56b301951402d614b9311250e5/pouchdb.gql.js#L635

@rstacruz
Copy link
Member

I don't think it's contrived at all, I've ran into it myself.

@rupe
Copy link

rupe commented Feb 27, 2015

It doesn't detect a break even if it isn't in an if statement. For example, the following gives an 'unexpected indentation' error:

function foo (data) {
  var i = 9;
  switch (data) {
    case 'foo':
      i = 99;
      break
    case 'bar':
      break;
  };
  while (i > 0) {
    i--
  };
};

@pronebird
Copy link
Collaborator

pronebird commented Mar 2, 2015

empy case produces empty when.

And when I convert from coffee to JS, even if I put empty ; inside of when, it gives back the funny code without break statement.

when 'bar'
  ;

case 'bar':

@tgaeta
Copy link

tgaeta commented Aug 24, 2015

I too receive the same:

screen shot 2015-08-24 at 4 56 59 pm

@tgaeta
Copy link

tgaeta commented Mar 29, 2016

I'm guessing this won't get fixed as this has been an issue for over a year, no response has been given, and the last release was in July of 2015.

@mralexgray
Copy link

mralexgray commented May 10, 2016

+1

AND

@tgaeta what editor is that?

@h4ck3rm1k3
Copy link

I am getting the same problem

https://github.com/opal/opal/blob/acba5f18fb45e1c226c015abbe2cb99a26121bf6/opal/corelib/kernel.rb#L342 this code is failing on the conversion

@Max-Tweddell
Copy link

@tgaeta what editor is that?

It is the js2.coffee website

This problem is frustrating, is there any way I could get around this?

@tgaeta
Copy link

tgaeta commented Jul 4, 2024

8 years later imageimage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants