PrismJS / PrismJS/prism

Go generic functions are not parsed correctly

Open
#3,729 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

Information:

  • Prism version: 1.29
  • Language: Go
  • Plugins: none
  • Environment: Browser

Description

The Go parser seems to get confused when generic type arguments are present (generics were added to go in 1.18 in March 2022). Using the Test drive from the Prism website, the screenshow below shows that the first Bar is parsed as a function, but the second Bar is parsed as punctuation instead of a function.

Screenshot 2023-09-17 at 6 26 00 PM

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Prism website Test drive and reproduce the supplied Go example containing generic type arguments. Then locate the Go parser or grammar responsible for the two Bar declarations and compare their highlighted token types; done when both function declarations are parsed consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.