skx/monkey

Constants are accidentally global

skx opened this issue · 1 comments

skx commented

The following code fails:

  const a =3;

  function foo() {
      let a = "Hello";
      puts( "A:" , a, "\n" );
  }
  puts( "A:", a, "\n");
  foo();

The output is:

  A:3
  Attempting to modify constant denied - a
skx commented

The problem here is that we look for constant-values recursively, rather than limiting them to the current scope. The fix is obvious :)