Incorrect lineno for property and class const variance check
Open
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';
}
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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