google / google/closure-compiler

goog.module doesn't allow local variables at top level (because of the translation to goog.scope)

Open
#1,083 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

This only occurs in goog.module.

``` javascript
goog.module("test");

const obj = {a: 5, b: 7};

let {a, b} = obj;
console.log(a);
a = 5;
console.log(a);
```

Result:

```
input0:7: ERROR - The alias a is assigned a value more than once.
a = 5;
^

1 error(s), 0 warning(s)
```

https://closure-compiler-debugger.appspot.com/#input0%3Dgoog.module(%2522test%2522)%253B%250A%250Aconst%2520obj%2520%253D%2520%257Ba%253A%25205%252C%2520b%253A%25207%257D%253B%250A%250Alet%2520%257Ba%252C%2520b%257D%2520%253D%2520obj%253B%250Aconsole.log(a)%253B%250Aa%2520%253D%25205%253B%250Aconsole.log(a)%253B%250A%26input1%26conformanceConfig%26externs%26refasterjs-template%26includeDefaultExterns%3D1%26CLOSURE_PASS%3D1%26LANG_IN_IS_ES6%3D1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.