-
Notifications
You must be signed in to change notification settings - Fork 13.2k
arguments should not be allowed in class static block
#48172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dc8f02a
`arguments` should not be allowed in class static block
Zzzen 9e6603c
update isInPropertyInitializerOrClassStaticBlock
Zzzen c036989
simplify implementation
Zzzen 5c37aa3
add tests
Zzzen 572b150
Merge branch 'main' into args-in-class-static-block
sandersn 0276f05
hereby format
sandersn 165e127
Update src/compiler/diagnosticMessages.json
Zzzen 1e50082
update baselines
Zzzen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 107 additions & 10 deletions
117
...ines/reference/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,141 @@ | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(3,10): error TS2815: 'arguments' cannot be referenced in property initializers. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(9,10): error TS2815: 'arguments' cannot be referenced in property initializers. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(15,15): error TS2815: 'arguments' cannot be referenced in property initializers. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(21,15): error TS2815: 'arguments' cannot be referenced in property initializers. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(3,10): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(9,10): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(15,15): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(21,15): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(33,16): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(40,7): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(42,16): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(57,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(60,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(66,6): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(75,7): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(77,9): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts(96,26): error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
|
|
||
|
|
||
| ==== tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts (4 errors) ==== | ||
| ==== tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts (13 errors) ==== | ||
| function A() { | ||
| return class T { | ||
| a = arguments | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers. | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| } | ||
| } | ||
|
|
||
| function A1() { | ||
| return new class T { | ||
| a = arguments | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers. | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| } | ||
| } | ||
|
|
||
| function B() { | ||
| return class T { | ||
| a = { b: arguments } | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers. | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| } | ||
| } | ||
|
|
||
| function B1() { | ||
| return new class T { | ||
| a = { b: arguments } | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers. | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| } | ||
| } | ||
|
|
||
| function C() { | ||
| return class T { | ||
| a = function () { arguments } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function D() { | ||
| return class T { | ||
| a = () => arguments // should error | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| } | ||
| } | ||
|
|
||
| function D1() { | ||
| return class T { | ||
| a = () => { | ||
| arguments; // should error | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| const b = () => { | ||
| return arguments; // should error | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| } | ||
|
|
||
| function f() { | ||
| return arguments; // ok | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function D2() { | ||
| return class { | ||
| constructor() { | ||
| arguments; // ok | ||
| } | ||
| get foo() { | ||
| ~~~ | ||
| !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. | ||
| return arguments; // ok | ||
| } | ||
| set foo(foo: any) { | ||
| ~~~ | ||
| !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. | ||
| arguments; // ok | ||
| } | ||
| bar() { | ||
| arguments; // ok | ||
| } | ||
| [Symbol.iterator]() { | ||
| ~~~~~~ | ||
| !!! error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. | ||
| arguments; // ok | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function D3() { | ||
| return class T { | ||
| static { | ||
| arguments; // should error | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| while(1) { | ||
| arguments // should error | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function D4() { | ||
| return class T { | ||
| static { | ||
| function f() { | ||
| arguments; // ok | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| function D5() { | ||
| return class T { | ||
| a = (() => { return arguments; })() // should error | ||
| ~~~~~~~~~ | ||
| !!! error TS2815: 'arguments' cannot be referenced in property initializers or class static initialization block. | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.