Skip to content
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

SWC should parse yield<T> (v: T)=>v #9914

Closed
magic-akari opened this issue Jan 21, 2025 · 2 comments · Fixed by #9915
Closed

SWC should parse yield<T> (v: T)=>v #9914

magic-akari opened this issue Jan 21, 2025 · 2 comments · Fixed by #9915
Assignees
Labels
Milestone

Comments

@magic-akari
Copy link
Member

magic-akari commented Jan 21, 2025

Describe the bug

sub issue of #9878

Input code

(function* () {
    yield <T>(v: T) => v;
});

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es2022"
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.10.9&code=H4sIAAAAAAAAA9NIK81LLsnMz9NS0NBUqOZSAILKzNScFAWbEDuNMiuFEE0FWzuFMmuuWk1rAMYyBAQtAAAA&config=H4sIAAAAAAAAA02NOQ6EMAxF%2B5wick2BUlBwBw4RgUFBLJFtpIkQd58kkBk6%2F%2FcXn0prmLmHVp%2FxjMJbYqSfjoTDJvYTCUjwyD05L1AVVzhZo10YM7puB8TShJJayKY2BtTjwboPx4L%2Fj2n1zjWvkNvcGMpyRo670hQ6UF1fU15err0AAAA%3D

SWC Info output

No response

Expected behavior

SWC should parse successfully.

Actual behavior

No response

Version

all

Additional context

No response

@magic-akari
Copy link
Member Author

Investigation: When JSX/TSX is enabled, this code can be correctly parsed.

CC @kdy1 Do you have any ideas?

@kdy1
Copy link
Member

kdy1 commented Jan 22, 2025

I tried cargo test --features debug 9914 and I found

  DEBUG  try_parse_ts__success_value: Some(;)
    at crates/swc_ecma_parser/src/parser/typescript.rs:626
    in try_parse_ts with cur: Some(< (jsx tag start))

So I think it's lexed as a start tag for a jsx element.

@kdy1 kdy1 closed this as completed in 04333aa Jan 24, 2025
@kdy1 kdy1 modified the milestones: Planned, v1.10.10 Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants