Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(446)

Issue 7577048: Don't check 'with' for undefined vars, but do record var declarations. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 3 months ago by usrbincc
Modified:
13 years, 2 months ago
Reviewers:
peterhal, arv, johnjbarton
CC:
traceur-compiler-reviews_googlegroups.com
Base URL:
https://code.google.com/p/traceur-compiler/@master
Visibility:
Public.

Description

Don't check 'with' for undefined vars, but do record declarations. There is no general way to statically analyze a 'with' statement for usage of undefined vars, so we only do what we can: add any declared vars and functions to our scope. BUG=https://code.google.com/p/traceur-compiler/issues/detail?id=207 TEST=test/feature/FreeVariableChecker/Error_With.js test/feature/FreeVariableChecker/WithBasic.js test/feature/FreeVariableChecker/WithVarDecl.js

Patch Set 1 #

Patch Set 2 : A (hopefully) correct implementation this time. #

Total comments: 6

Patch Set 3 : Use a less tricky technique. Update comment. #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+63 lines, -0 lines) Patch
M src/semantics/FreeVariableChecker.js View 1 2 4 chunks +18 lines, -0 lines 0 comments Download
A test/feature/FreeVariableChecker/Error_With.js View 1 chunk +7 lines, -0 lines 0 comments Download
A test/feature/FreeVariableChecker/WithBasic.js View 1 chunk +13 lines, -0 lines 0 comments Download
A test/feature/FreeVariableChecker/WithVarDecl.js View 1 1 chunk +25 lines, -0 lines 2 comments Download

Messages

Total messages: 6
usrbincc
I've been letting a lot of patches just sit there, which is not a good ...
13 years, 2 months ago (2013-03-22 20:52:09 UTC) #1
arv
https://codereview.appspot.com/7577048/diff/4001/src/semantics/FreeVariableChecker.js File src/semantics/FreeVariableChecker.js (right): https://codereview.appspot.com/7577048/diff/4001/src/semantics/FreeVariableChecker.js#newcode85 src/semantics/FreeVariableChecker.js:85: RecordOnly.prototype = this; On 2013/03/22 20:52:09, usrbincc wrote: > ...
13 years, 2 months ago (2013-03-22 22:01:04 UTC) #2
usrbincc
Got rid of the weird proxy object technique. I still think it's kind of interesting. ...
13 years, 2 months ago (2013-03-23 20:46:00 UTC) #3
arv
LGTM https://codereview.appspot.com/7577048/diff/4001/src/semantics/FreeVariableChecker.js File src/semantics/FreeVariableChecker.js (right): https://codereview.appspot.com/7577048/diff/4001/src/semantics/FreeVariableChecker.js#newcode85 src/semantics/FreeVariableChecker.js:85: RecordOnly.prototype = this; On 2013/03/23 20:46:00, usrbincc wrote: ...
13 years, 2 months ago (2013-03-24 14:30:22 UTC) #4
arv
Committed as f6a3d21a18bea1191cf90878f95aabaea9d325df
13 years, 2 months ago (2013-03-24 14:32:41 UTC) #5
usrbincc
13 years, 2 months ago (2013-03-25 18:09:38 UTC) #6
https://codereview.appspot.com/7577048/diff/12001/test/feature/FreeVariableCh...
File test/feature/FreeVariableChecker/WithVarDecl.js (right):

https://codereview.appspot.com/7577048/diff/12001/test/feature/FreeVariableCh...
test/feature/FreeVariableChecker/WithVarDecl.js:6: function funcW(x, y) { return
y / x + x; }
On 2013/03/24 14:30:22, arv-chromium wrote:
> This is actually not allowed in any version of ECMAScript. All script
> engines allow it though so I guess it is good that we allow it too.

If it's explicitly disallowed, maybe we should (eventually) flag it as
an error. Low priority "should", since it's not really a common pattern,
and people should be using strict mode anyway. But still.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b