alongubkin / alongubkin/spider

Allow accessing global variable with `::` with a local with the same name in scope

Open
#115 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
1.3k
Forks
46
PR merge metrics
No merged PRs in 30d

Description

I expected this to work:

```
::x = 5;
fn addToX(x) {
return ::x + x;
}
::console.log(addToX(2)); // 7
```

However it compiles to (with ES6 target):

``` js
"use strict";
(function () {
x = 5;
function addToX(x) {
return x + x;
}
console.log(addToX(2)); // 4
}());
```

The compiler should maybe rename the local `x` so that the `::x` accesses the global `x`:

``` js
x = 5;
function addToX(x_) {
return x + x_;
}
```

The same should hold for local variables, and for `use`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.