microsoft / microsoft/tolerant-php-parser

Function names cannot be keywords

Open
#236 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
894
Forks
85
Avg merge
2d 13h
Merged PRs (30d)
3

Description

Summary
A function name must be a T_STRING token (or whatever its equivalent is in this parser).

Sample code:
function empty() {}

Expected
Parse error: syntax error, unexpected 'empty' (T_EMPTY), expecting '('

Actual
No error.

Contributor guide

Open the contributing guide

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 by locating the parser rule that accepts function declarations and the token definitions for T_STRING and T_EMPTY. Reproduce the sample function empty() {} and compare its result with the expected parse error. Done means keyword-named functions are rejected while ordinary function names continue to parse correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
compilers
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.