Skip to content

Expect parser error but not for empty generic list #11119

@bvanjoi

Description

@bvanjoi

Describe the bug

An empty generic list is considered a grammar error and should therefore be reported.

Image

Input code

class I<T> {}
var x: I<>;

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es2024",
    "loose": false,
    "minify": {
      "compress": {
        "arguments": false,
        "arrows": true,
        "booleans": true,
        "booleans_as_integers": false,
        "collapse_vars": true,
        "comparisons": true,
        "computed_props": true,
        "conditionals": true,
        "dead_code": true,
        "directives": true,
        "drop_console": false,
        "drop_debugger": true,
        "evaluate": true,
        "expression": false,
        "hoist_funs": false,
        "hoist_props": true,
        "hoist_vars": false,
        "if_return": true,
        "join_vars": true,
        "keep_classnames": false,
        "keep_fargs": true,
        "keep_fnames": false,
        "keep_infinity": false,
        "loops": true,
        "negate_iife": true,
        "properties": true,
        "reduce_funcs": false,
        "reduce_vars": false,
        "side_effects": true,
        "switches": true,
        "typeofs": true,
        "unsafe": false,
        "unsafe_arrows": false,
        "unsafe_comps": false,
        "unsafe_Function": false,
        "unsafe_math": false,
        "unsafe_symbols": false,
        "unsafe_methods": false,
        "unsafe_proto": false,
        "unsafe_regexp": false,
        "unsafe_undefined": false,
        "unused": true,
        "const_to_let": true,
        "pristine_globals": true
      },
      "mangle": {
        "toplevel": false,
        "keep_classnames": false,
        "keep_fnames": false,
        "keep_private_props": false,
        "ie8": false,
        "safari10": false
      }
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.13.5&code=H4sIAAAAAAAAA0vOSSwuVvC0CbFTqK7lKkssUqiwAnLtrAGVHjcSGQAAAA%3D%3D&config=H4sIAAAAAAAAA41VwW7bMAy99ysCn3foimIo9gG77RsExaIcdbJoiJSboMi%2Fl1bsNG1oY5cg5tMjRfKRen%2FY7ZpXapvfu3f5Kx%2BDzQT5%2Bi0WOiW2R7E0fBqA2hwGbn4sKNMEeRsJqul8QRq2uQOeWEBPj0%2FPM6OJiAQLY7b1IQV%2Fuo3ZYj9kILqxiVVclh4S01f%2BjGV8mwDO5da%2BR4xg0wZiLJmQGDrImuMWY7QDgRltVrxMN7U5EGohJrAwODNkHFQ8ucABk8S8Rx1YZ1p0oEAhQ8thBI0msYSWSNJT8qmwg33putrnb2wYbSyWlZhwrC2R2ypeDxiIjS9JK%2BEFXKnBBZyL%2B50ZvMnAJad73iuGtNKTfwBSgWiJku1B81tPeNHTGttvMkPyIlk%2BKbjoW8syQSdFNSF4pbJTZSBz0LqZwZUWpsq22nVmeKV8FBwY8F60orimt8DtQQs6DTp6BZD%2BWq%2Bp6gKY6xSu4NNAbMB%2FJEvWBTaf6C0f1lE69XuMGwF64AO6jQPSCsZ1OMuWOA7reEkORBrg1COFKnC%2FBGQAGE2s%2B%2FJOGzIe4tF0Efefa2I%2BcL7u4d6mrs77zb5kHCKMENdk%2FB8jsonK3cZJ1ctk300vvGiitDJ44efjl2dDUnlYfmtSTY%2Bu3CRUNXl5Tn41n4eWl%2BMapAn0d2HWQp0%2FANOpRJrkBgAA

SWC Info output

No response

Expected behavior

Expect throw parser error at I<>: Type argument list cannot be empty.

Actual behavior

Parse success.

Version

1.13.5

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions