Skip to content

Babili not validating values properly #581

@Rud156

Description

@Rud156

If something like this is put through Babili:

let pre = false;
let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let randomNumber = Math.floor(Math.random() * 5);
for(let i = 0; i < array.length; i++)
  if(randomNumber === array[i]){
    pre = true;
    break;
  }
if(!pre)
  console.log("Hello");

Then it splits out:

"use strict";for(var array=[1,2,3,4,5,6,7,8,9,10],randomNumber=Math.floor(5*Math.random()),i=0;i<array.length;i++)if(randomNumber===array[i]){break}pre||console.log("Hello");

The above mentioned code will fail as the variable pre is not defined but is used in a "strict" environment. There are other ways to implement the above code like using a return instead of break. But this methods fails. Looks like a BUG

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bugwith es2015The bug is caused when used with es2015-block-scoping plugin

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions