WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
208976
Catch parameters must not be lexically redeclared
https://bugs.webkit.org/show_bug.cgi?id=208976
Summary
Catch parameters must not be lexically redeclared
Ross Kirsling
Reported
2020-03-11 22:58:25 PDT
Catch parameters must not be lexically redeclared
Attachments
Patch
(9.51 KB, patch)
2020-03-11 23:17 PDT
,
Ross Kirsling
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Ross Kirsling
Comment 1
2020-03-11 23:17:22 PDT
Created
attachment 393344
[details]
Patch
Ross Kirsling
Comment 2
2020-03-11 23:21:44 PDT
Comment on
attachment 393344
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=393344&action=review
> Source/JavaScriptCore/parser/Parser.h:1648 > - template <class TreeBuilder> TreeStatement parseBlockStatement(TreeBuilder&); > + template <class TreeBuilder> TreeStatement parseBlockStatement(TreeBuilder&, bool isCatchBlock = false);
I know this isn't the greatest, but if we don't mark the catch block scope itself, our error checking would blimp out to something like this: if (scope.hasContainingScope()) { ScopeRef containingScope = scope.containingScope(); if (containingScope->catchParameterScopeType() != CatchParameterScopeType::None && containingScope->hasLexicallyDeclaredVariable(*ident)) return DeclarationResult::InvalidDuplicateDeclaration; }
Keith Miller
Comment 3
2020-03-16 16:36:55 PDT
Comment on
attachment 393344
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=393344&action=review
>> Source/JavaScriptCore/parser/Parser.h:1648 >> + template <class TreeBuilder> TreeStatement parseBlockStatement(TreeBuilder&, bool isCatchBlock = false); > > I know this isn't the greatest, but if we don't mark the catch block scope itself, our error checking would blimp out to something like this: > > if (scope.hasContainingScope()) { > ScopeRef containingScope = scope.containingScope(); > if (containingScope->catchParameterScopeType() != CatchParameterScopeType::None && containingScope->hasLexicallyDeclaredVariable(*ident)) > return DeclarationResult::InvalidDuplicateDeclaration; > }
Why can't we just use the catch parameter's scope as the block's scope?
Ross Kirsling
Comment 4
2020-03-16 16:43:59 PDT
(In reply to Keith Miller from
comment #3
)
> Why can't we just use the catch parameter's scope as the block's scope?
I tried that briefly but it seemed like the very test you fixed in
bug 189914
was expecting them to be separate. Looking more closely now though, I feel like this shouldn't be the case, so maybe I had something else mistaken.
Ross Kirsling
Comment 5
2020-03-17 17:40:01 PDT
(In reply to Ross Kirsling from
comment #4
)
> (In reply to Keith Miller from
comment #3
) > > Why can't we just use the catch parameter's scope as the block's scope? > > I tried that briefly but it seemed like the very test you fixed in bug > 189914 was expecting them to be separate. Looking more closely now though, I > feel like this shouldn't be the case, so maybe I had something else mistaken.
So that *particular* test failing was my own mistake, but there is a neighboring test which specifically ensures that the param scope is separate from the block scope:
https://github.com/tc39/test262/blob/master/test/language/statements/try/scope-catch-block-lex-open.js
Was a good exercise to verify though. :P
Ross Kirsling
Comment 6
2020-03-19 14:24:29 PDT
Ping?
Keith Miller
Comment 7
2020-03-23 11:18:38 PDT
(In reply to Ross Kirsling from
comment #5
)
> (In reply to Ross Kirsling from
comment #4
) > > (In reply to Keith Miller from
comment #3
) > > > Why can't we just use the catch parameter's scope as the block's scope? > > > > I tried that briefly but it seemed like the very test you fixed in bug > > 189914 was expecting them to be separate. Looking more closely now though, I > > feel like this shouldn't be the case, so maybe I had something else mistaken. > > So that *particular* test failing was my own mistake, but there is a > neighboring test which specifically ensures that the param scope is separate > from the block scope: >
https://github.com/tc39/test262/blob/master/test/language/statements/try/
> scope-catch-block-lex-open.js > > Was a good exercise to verify though. :P
Ahh, lame, I guess that makes sense though...
Keith Miller
Comment 8
2020-03-23 11:19:21 PDT
Comment on
attachment 393344
[details]
Patch r=me.
EWS
Comment 9
2020-03-23 11:23:56 PDT
Committed
r258861
: <
https://trac.webkit.org/changeset/258861
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 393344
[details]
.
Radar WebKit Bug Importer
Comment 10
2020-03-23 11:24:12 PDT
<
rdar://problem/60783189
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug