`Emissions.emitArg` branches into two identical arms in `Emissions.java`

Open Beginner friendly
#8,602 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start at emitArg in eo-parser/src/main/java/org/eolang/parser/Emissions.java:173 and compare ChainEmission.link at ChainEmission.java:108. Remove the duplicate branch by using the shared path, preserving the @as slot, @const marker, and close handling for both chained and unchained arguments.

Written by the indexing model from the issue text.

Description

Emissions.emitArg at eo-parser/src/main/java/org/eolang/parser/Emissions.java:173 branches on whether the argument carries a .method chain and then writes the same eight lines in both arms. The chained arm calls ChainEmission.link(emit, line, value, tail, null); the unchained one calls Emissions.openValue(emit, null, value, line), which is precisely what link does for an empty chain at ChainEmission.java:108 — with label being the same null the caller hands it, and the loop that follows running zero times. The @as slot, the @const marker and the close after them are identical on both sides.

The condition is left over from bfad5b019c, the fix for #6982, which pointed the chained arm at ChainEmission.link and left the other one on the direct call it used before. What remains is a guard against the code it is guarding, and two copies of the argument's binding and const handling that can only ever drift apart by hand.

Calling ChainEmission.link unconditionally and deleting the branch removes about ten lines and leaves one path through emitArg for a chained and an unchained argument alike.

@yegor256 please take a look

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.