Skip to content

A lethal combo. #420

Closed
Closed

Description

@WebReflection

Apologies for the fancy bug title but I couldn't think of any more descriptive one.

I've managed to isolate a series of issues in a single snippet that fails with babili 0.0.11

const that = (...args) => {
  let i = args.length;
  if (!i) return;
  else {
    const info = {args};
    while (false);
    return info;
  }
};

Despite being useless, it's valid JS syntax that's part of the real-world logic I am using.

How to make above snippet not to fail?

Please note the following is a list of OR conditions.
Each point itself will change the result, making babili happy.

  • use do ; while(false); instead
  • avoid the creation of the info constant and return directly return {args};
  • keep the info but return {args}; instead
  • drop the else and use if (i) { instead
  • don't access args.length and let i = 1;
  • drop the while(false) line
  • use if (false); instead of while (false);

Thanks in advance for figuring out how come such little snippets can produce so many failures/not-failures scenarios.

Activity

  1. added
    bug
    on Feb 11, 2017
  2. boopathi commented on Feb 11, 2017

    @boopathi
    Member

    Nice example.

    With #408, the output is

    const that = (...a) => {
      let b = a.length;
      if (!b) return;
    
      return { args: a };
    };

    but still, it should be

    const that = (...a) => {
      let b = a.length;
      if (b) return { args: a };
    };

    Ultimately, it could be

    const that = (...a) => a.length ? {args: a} : void 0;

    But, because we treat a.length to possibly be a side-effecty getter and not computing side-effects between defn of b and usage of b (yet) (#221) , we are not able to safely replace it.

  3. WebReflection commented on Feb 11, 2017

    @WebReflection
    Author

    Please also keep in mind in my case I had to create a new variable in order to circumvent the failure.

  4. added
    has PR
    on Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughas PR

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions