PrismJS / PrismJS/prism

from and revert are highlighted as keywords in Solidity code everywhere

Open
#3,980 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.30.0
  • Plugins: none
  • Environment: browser

Description

from should only be highlighted as a keyword in Solidity when used in import statements.
revert should only be highlighted as a keyword in Solidity when used in revert statements.

test case:

function f(address from) virtual  {}
function g(bool revert) virtual {}

Note that there is this rule in Solidity's grammar:

https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityParser.identifier

/**
 * Besides regular non-keyword Identifiers, some keywords like 'from' and 'error' can also be used as identifiers.
 */
identifier: Identifier | From | Error | Revert | Global | Transient | Layout | At;

docs/grammar/SolidityParser.g4#L425-L428

Example
https://prismjs.com/test#language=solidity&text=function%20f(address%20from)%20virtual%20%20%7B%7D%0Afunction%20g(bool%20revert)%20virtual%20%7B%7D

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

Use the provided Solidity test case in the Prism test page and consult SolidityParser.g4 lines 425-428 to confirm the allowed identifier contexts. Update the Solidity highlighting behavior so from and revert are keywords only in their statement contexts, then verify the example no longer highlights them as parameter names.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, solidity
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.