Skip to content

Refuse an identifier the parser cannot complete - #16

Merged
MaximBelov merged 1 commit into
masterfrom
fix/incomplete-ai
Aug 13, 2026
Merged

MaximBelov merged 1 commit into
masterfrom
fix/incomplete-ai

Conversation

@MaximBelov

Copy link
Copy Markdown
Owner

parseBarcode("]C1430") returned a successful parse whose one element was "":

parseBarcode("]C1430").parsedCodeItems   // [""]  — no error

Several inner switches carry no default arm, so when the digit they are about to read is missing — or names something the parser does not know — nothing matches, nothing parses, and the element being built is left the empty string it started as. It then gets pushed onto the answer.

26 three digit prefixes did this: 230-234, 236-239, 430-433, 701, 702, 704, 720-722, 724-729, 803. Some are a real family with the last digit missing (430x); others name nothing the standard defines (230x, where 235 is the only one there is).

Now refused with unrecognised AI. The guard sits at the end of the identifier switch rather than in each arm, so an identifier added later without a default cannot bring it back.

403 specs, 0 failures in UTC, Dublin and New York. Coverage still 100%.

One correction to the changelog

The isoDate entry from #15 was sitting under ## 1.1.0, but 1.1.0 was published before #15 merged — the released package does not contain it. Moved to a fresh unreleased section, along with this fix.

Several of the inner switches carry no default arm, so when the digit one of
them is about to read is missing, or names something the parser does not know,
nothing matches and nothing parses. elementToReturn was then left the empty
string it started as and pushed onto the answer, so parseBarcode("]C1430")
came back as a successful parse whose one element was "".

It happened for 26 three digit prefixes. Some are a real family with the last
digit missing, 430x among them; others name nothing the standard defines, 230x
among them, where 235 is the only identifier there is.

The guard sits at the end of the identifier switch rather than in each arm, so
an identifier added later without a default cannot bring the fault back.

Also moves the isoDate entry in the changelog out of 1.1.0 and into a fresh
unreleased section. 1.1.0 was published before that change merged, so the entry
was describing something the release does not contain.
@MaximBelov
MaximBelov merged commit 633e49b into master Aug 13, 2026
1 check passed
@MaximBelov MaximBelov mentioned this pull request Aug 13, 2026
@MaximBelov
MaximBelov deleted the fix/incomplete-ai branch August 13, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant