Static method `new` is unsupported in generics
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Reproduce the issue with the PHP generic example and inspect the parser path reported in gentree.cpp:1333 and gentree.cpp:1641. Compare handling of $t::new() with the later ::abc() diagnostic from replace-extern-func-calls.cpp:91. Done means the generic class-string example compiles while unresolved methods still produce the expected error.
Written by the indexing model from the issue text.
Description
<?php
class Foo {
}
_main();
function _main() {
new_t(Foo::class);
}
/**
* @kphp-generic T
* @param class-string<T> $t
*/
function new_t($t) {
$t::new();
}
fails to compile with following errors:
Compilation error at stage: Parse file, gen by gentree.cpp:1333
4dbee3a5.php:18 in new_t<T>
$t::new();
Unrecognized syntax after '$t::'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compilation error at stage: Parse file, gen by gentree.cpp:1641
4dbee3a5.php:18 in new_t<T>
$t::new();
Failed to parse statement. Expected `;`
Changing call of ::new() to ::abc() gives correct error:
Compilation error at stage: Check func calls and vararg, gen by replace-extern-func-calls.cpp:91
dd8b4e3e.php:18 in new_t<Foo> (instantiated at dd8b4e3e.php:10)
$t::abc();
Syntax '$class_name::method()' not resolved: method abc not found in class Foo
- Dominant language
- C++
- Stars
- 1.5k
- Forks
- 116
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 11
Contributor guide
No contributing guide indexed for this repository
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.
More from VKCOM/kphp
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
-
Khan Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
-
.github/CODEOWNERS Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·