Runtime crashes when an object receives more positional arguments than its voids
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start with PhDefault.vacancy() at PhDefault.java:410-422 and AtOnce.put() at AtOnce.java:67-74, then read PhDefault.attr() for the existing error-message shape. Run PhDefaultTest.failsCorrectlyWhenTooManyAttributesPut and make the too-many-positional-arguments failure identify the object, position, and void count without exposing AtComposite's default text.
Written by the indexing model from the issue text.
Description
What happens
When an application hands an object more positional arguments than it has voids, the runtime dies with
Can't overwrite the cached attribute "org.eolang.AtComposite@20f5239f"
That message names neither the object that received the argument, nor the attribute it landed on, nor the position. The program that hit it in #8651 was
Q.stdout
Q.string.printf
"%dth Fibonacci number is %d\n"
* n f
against [^ args] > printf: the second argument has no void left to take, so it lands on the bound φ. Finding that out took a --verbose run and reading the last 𝔸(...) line before the trace; the message itself gave nothing to start from.
Where it comes from
PhDefault.vacancy() (PhDefault.java:410-422) looks for a vacant attribute at pos and after it, and when there is none it keeps the name at pos and hands the put to whatever attribute sits there. For a bound attribute that is an AtOnce, whose put() (AtOnce.java:67-74) throws ExReadOnly with this.origin in the text, and AtComposite has no toString(), so the text is the default Object.toString().
The neighbouring checks in PhDefault.attr() do say what is wrong: %s has just %d attribute(s), can't read the %d-th one. This case is the same mistake, one void short instead of one attribute short, and it is the only one of the three that reports a cache instead of a count.
PhDefaultTest.failsCorrectlyWhenTooManyAttributesPut pins the current text and calls it "the message explains what's going on".
Steps to reproduce
final Phi printf = Phi.Φ.take("string").take("printf");
printf.put(0, new Data.ToPhi("%d"));
printf.put(1, new Data.ToPhi(1));
or any EO application with one positional argument more than the object has voids, as the one above.
Expected behavior
The error says which object was given a positional argument it has no void for, at which position, and how many voids it has, in the shape attr() already uses; the internal AtComposite@... never reaches the user.
- Dominant language
- Java
- Stars
- 1.5k
- Forks
- 251
- Avg merge
- 22h 52m
- Merged PRs (30d)
- 653
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 objectionary/eo
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
objectionary/eo#8869 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/eo#8853 ·
-
bug good-title
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
objectionary/eo#8852 ·
-
bug good-title
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
objectionary/eo#8851 ·
-
bug good-title
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
objectionary/eo#8850 ·
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100