`eo-parser` incorrectly rejects method chain on identity object `I` as a horizontal argument

Open Beginner friendly
#7,567 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
compilers

Research direction

Start with eo-parser/src/main/java/org/eolang/parser/Tokens.java, especially readArg(), and compare its handling with Value.chainable() in Value.java; consult the parser specification section R-3.16.1. Reproduce the three forms from the issue, then verify that foo I.bar is accepted as a horizontal argument while I 5 remains restricted.

Written by the indexing model from the issue text.

Description

bug good-title help wanted

What happens

The identity object is accepted as a horizontal argument, and a method chain on it is accepted when it is the line head, but the combination is rejected:

[] > main
  foo I.bar > result

Current master reports:

[2:7] error: 'trailing garbage after expression'
  foo I.bar > result
       ^

The parser accepts both neighbouring forms:

source result
foo I > result accepted
I.bar > result accepted
foo I.bar > result rejected at .

Tokens.readArg() reads a trailing chain only for the kinds listed by Value.chainable(); IDENTITY is not one of them.

Why this is a bug

This is not the horizontal-argument form rejected in #7477. I receives no argument here: it is the receiver of .bar, and the resulting I.bar expression is the sole argument of foo.

The parser specification describes I as a value recognised wherever a value is expected and says it may carry a method chain (R-3.16.1). A method chain on an argument is already supported for literals and identifiers, for example foo 42.as-bytes.

Expected behavior

Accept foo I.bar and emit the method chain as the horizontal argument. The restriction on applying horizontal arguments to I (I 5) can remain unchanged.

How it was verified

Compiled eo-parser from current master in an isolated temporary output directory and parsed all three forms in the table above. Only the chained-argument form produced a parser error.

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

  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.

More from objectionary/eo

All issues in objectionary/eo

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.