php / php/php-src

Incorrect lineno for property and class const variance check

Open
#14,874 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Category: Engine Feature Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

The following code:

<?php

class C extends P {
    public const int X = 42;
}

class P {
    public const string X = 'X';
}

https://3v4l.org/IKY5H#v8.3.9

Resulted in this output:

Fatal error: Type of C::X must be compatible with P::X of type string in /in/ZAZYv on line 3

But I expected this output instead:

Fatal error: Type of C::X must be compatible with P::X of type string in /in/ZAZYv on line 4

Same goes for properties. From property hooks feedback:

https://github.com/php/php-src/pull/13455#discussion_r1499322256

PHP Version

*

Operating System

No response

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

Reproduce the class-constant example and compare the reported line with the expected line 4, then investigate the variance-check diagnostic path in the PHP interpreter. Check the analogous property case referenced in the property hooks feedback; done means both property and class-constant errors report the declaration line of the incompatible child member.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.