mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(semantic): report type parameter list cannot be empty (#2315)
This commit is contained in:
parent
a762d17603
commit
9ca13d040d
3 changed files with 109 additions and 6 deletions
|
|
@ -21,11 +21,27 @@ impl EarlyErrorTypeScript {
|
|||
AstKind::SimpleAssignmentTarget(target) => check_simple_assignment_target(target, ctx),
|
||||
AstKind::FormalParameters(params) => check_formal_parameters(params, ctx),
|
||||
AstKind::ArrayPattern(pattern) => check_array_pattern(pattern, ctx),
|
||||
AstKind::TSTypeParameterDeclaration(declaration) => {
|
||||
check_ts_type_parameter_declaration(declaration, ctx);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_ts_type_parameter_declaration(
|
||||
declaration: &TSTypeParameterDeclaration<'_>,
|
||||
ctx: &SemanticBuilder<'_>,
|
||||
) {
|
||||
#[derive(Debug, Error, Diagnostic)]
|
||||
#[error("Type parameter list cannot be empty.")]
|
||||
#[diagnostic()]
|
||||
struct EmptyTypeParameterList(#[label] Span);
|
||||
if declaration.params.is_empty() {
|
||||
ctx.error(EmptyTypeParameterList(declaration.span));
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
fn check_variable_declarator(decl: &VariableDeclarator, ctx: &SemanticBuilder<'_>) {
|
||||
#[derive(Debug, Error, Diagnostic)]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
parser_babel Summary:
|
||||
AST Parsed : 2090/2096 (99.71%)
|
||||
Positive Passed: 2086/2096 (99.52%)
|
||||
Negative Passed: 1358/1500 (90.53%)
|
||||
Negative Passed: 1360/1500 (90.67%)
|
||||
Expect Syntax Error: "annex-b/disabled/1.1-html-comments-close/input.js"
|
||||
Expect Syntax Error: "annex-b/disabled/3.1-sloppy-labeled-functions/input.js"
|
||||
Expect Syntax Error: "annex-b/disabled/3.1-sloppy-labeled-functions-if-body/input.js"
|
||||
|
|
@ -61,7 +61,6 @@ Expect Syntax Error: "typescript/class/declare-readonly-field-initializer-w-anno
|
|||
Expect Syntax Error: "typescript/class/duplicate-modifier-1/input.ts"
|
||||
Expect Syntax Error: "typescript/class/duplicate-modifier-2/input.ts"
|
||||
Expect Syntax Error: "typescript/class/duplicates-accessibility/input.ts"
|
||||
Expect Syntax Error: "typescript/class/empty-type-parameters/input.ts"
|
||||
Expect Syntax Error: "typescript/class/generator-method-with-modifiers/input.ts"
|
||||
Expect Syntax Error: "typescript/class/index-signature-errors/input.ts"
|
||||
Expect Syntax Error: "typescript/class/invalid-modifiers-order/input.ts"
|
||||
|
|
@ -92,7 +91,6 @@ Expect Syntax Error: "typescript/expect-plugin/export-type/input.js"
|
|||
Expect Syntax Error: "typescript/expect-plugin/export-type-named/input.js"
|
||||
Expect Syntax Error: "typescript/export/double-declare/input.ts"
|
||||
Expect Syntax Error: "typescript/export/equals-in-script/input.ts"
|
||||
Expect Syntax Error: "typescript/function/empty-type-parameters/input.ts"
|
||||
Expect Syntax Error: "typescript/import/equals-in-script/input.ts"
|
||||
Expect Syntax Error: "typescript/import/equals-require-in-script/input.ts"
|
||||
Expect Syntax Error: "typescript/import/export-import-type/input.ts"
|
||||
|
|
@ -9733,6 +9731,12 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts"
|
|||
╰────
|
||||
help: Try insert a semicolon here
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[typescript/class/empty-type-parameters/input.ts:1:8]
|
||||
1 │ class C<> {}
|
||||
· ──
|
||||
╰────
|
||||
|
||||
× Expected `{` but found `EOF`
|
||||
╭─[typescript/class/extends-empty/input.ts:2:1]
|
||||
2 │ }
|
||||
|
|
@ -9880,6 +9884,12 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts"
|
|||
· ───
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[typescript/function/empty-type-parameters/input.ts:1:13]
|
||||
1 │ function foo<>() {}
|
||||
· ──
|
||||
╰────
|
||||
|
||||
× A parameter property is only allowed in a constructor implementation.
|
||||
╭─[typescript/function/parameter-properties/input.ts:3:3]
|
||||
2 │ readonly r,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
parser_typescript Summary:
|
||||
AST Parsed : 5239/5243 (99.92%)
|
||||
Positive Passed: 5232/5243 (99.79%)
|
||||
Negative Passed: 1036/4879 (21.23%)
|
||||
Negative Passed: 1038/4879 (21.27%)
|
||||
Expect Syntax Error: "compiler/ClassDeclaration10.ts"
|
||||
Expect Syntax Error: "compiler/ClassDeclaration11.ts"
|
||||
Expect Syntax Error: "compiler/ClassDeclaration13.ts"
|
||||
|
|
@ -306,7 +306,6 @@ Expect Syntax Error: "compiler/classStaticPropertyAccess.ts"
|
|||
Expect Syntax Error: "compiler/classTypeParametersInStatics.ts"
|
||||
Expect Syntax Error: "compiler/classUsedBeforeInitializedVariables.ts"
|
||||
Expect Syntax Error: "compiler/classWithDuplicateIdentifier.ts"
|
||||
Expect Syntax Error: "compiler/classWithEmptyTypeParameter.ts"
|
||||
Expect Syntax Error: "compiler/classWithMultipleBaseClasses.ts"
|
||||
Expect Syntax Error: "compiler/classWithOverloadImplementationOfWrongName.ts"
|
||||
Expect Syntax Error: "compiler/classWithOverloadImplementationOfWrongName2.ts"
|
||||
|
|
@ -3100,7 +3099,6 @@ Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parse
|
|||
Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts"
|
||||
Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts"
|
||||
Expect Syntax Error: "conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration10.ts"
|
||||
Expect Syntax Error: "conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts"
|
||||
Expect Syntax Error: "conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration2.ts"
|
||||
Expect Syntax Error: "conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts"
|
||||
Expect Syntax Error: "conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration6.ts"
|
||||
|
|
@ -4821,6 +4819,13 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts"
|
|||
╰────
|
||||
help: Try insert a semicolon here
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[compiler/classWithEmptyTypeParameter.ts:1:8]
|
||||
1 │ class C<> {
|
||||
· ──
|
||||
2 │ }
|
||||
╰────
|
||||
|
||||
× Cannot assign to 'arguments' in strict mode
|
||||
╭─[compiler/collisionArgumentsClassConstructor.ts:3:31]
|
||||
2 │ class c1 {
|
||||
|
|
@ -8148,6 +8153,70 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts"
|
|||
· ─
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[compiler/parserConstructorDeclaration12.ts:2:14]
|
||||
1 │ class C {
|
||||
2 │ constructor<>() { }
|
||||
· ──
|
||||
3 │ constructor<> () { }
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[compiler/parserConstructorDeclaration12.ts:3:14]
|
||||
2 │ constructor<>() { }
|
||||
3 │ constructor<> () { }
|
||||
· ──
|
||||
4 │ constructor <>() { }
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[compiler/parserConstructorDeclaration12.ts:4:15]
|
||||
3 │ constructor<> () { }
|
||||
4 │ constructor <>() { }
|
||||
· ──
|
||||
5 │ constructor <> () { }
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[compiler/parserConstructorDeclaration12.ts:5:15]
|
||||
4 │ constructor <>() { }
|
||||
5 │ constructor <> () { }
|
||||
· ──
|
||||
6 │ constructor< >() { }
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[compiler/parserConstructorDeclaration12.ts:6:14]
|
||||
5 │ constructor <> () { }
|
||||
6 │ constructor< >() { }
|
||||
· ───
|
||||
7 │ constructor< > () { }
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[compiler/parserConstructorDeclaration12.ts:7:14]
|
||||
6 │ constructor< >() { }
|
||||
7 │ constructor< > () { }
|
||||
· ───
|
||||
8 │ constructor < >() { }
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[compiler/parserConstructorDeclaration12.ts:8:15]
|
||||
7 │ constructor< > () { }
|
||||
8 │ constructor < >() { }
|
||||
· ───
|
||||
9 │ constructor < > () { }
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[compiler/parserConstructorDeclaration12.ts:9:15]
|
||||
8 │ constructor < >() { }
|
||||
9 │ constructor < > () { }
|
||||
· ───
|
||||
10 │ }
|
||||
╰────
|
||||
|
||||
× Multiple constructor implementations are not allowed.
|
||||
╭─[compiler/parserConstructorDeclaration12.ts:2:3]
|
||||
1 │ class C {
|
||||
|
|
@ -16202,6 +16271,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts"
|
|||
· ╰── `,` expected
|
||||
╰────
|
||||
|
||||
× Type parameter list cannot be empty.
|
||||
╭─[conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts:2:14]
|
||||
1 │ class C {
|
||||
2 │ constructor<>() { }
|
||||
· ──
|
||||
3 │ }
|
||||
╰────
|
||||
|
||||
× Expected a semicolon or an implicit semicolon after a statement, but found none
|
||||
╭─[conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration3.ts:2:9]
|
||||
1 │ class C {
|
||||
|
|
|
|||
Loading…
Reference in a new issue