fix: parse quoted reserved words as string literals - #64
Merged
dprevost-LMI merged 4 commits intoJul 1, 2026
Merged
Conversation
3 tasks
titusfortner
force-pushed
the
fix/quoted-reserved-word-literals
branch
from
June 25, 2026 19:12
e5b2ee2 to
2eb87a5
Compare
titusfortner
added a commit
to SeleniumHQ/selenium
that referenced
this pull request
Jun 26, 2026
) * [js] Add binding-neutral BiDi schema with cddl2ts-gated fidelity * [js] Project NullValue's quoted "null" tag as a string const (works around webdriverio/cddl#64)
13 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A quoted string whose text matches a reserved type keyword (
"null","bool","int","text", …) or a boolean literal ("true"/"false") was parsed as the native type instead of a string literal, and that bug propagated into every code generator (cddl2java,cddl2ts,cddl2py,cddl2swift,cddl2kotlin).The WebDriver BiDi grammar shows it directly. These two definitions are structurally identical — a single constant-string discriminator:
…but they parsed differently:
"undefined"parsed correctly only because there is noundefinedkeyword case, which is what made the inconsistency visible.Fixes
1. Parser (
cddl)In
parsePropertyType(), the type switch keyed offcurToken.Literal(the token text) rather thancurToken.Type. A quoted"null"is aSTRINGtoken whoseLiteralisnull, so it collided withcase Type.NULL. Separately, thedefaultbranch checkedBOOLEAN_LITERALSbefore theSTRINGbranch, so"true"/"false"became real booleans.The fix forces
STRINGtokens into the literal branch: the keyword switch is skipped for string tokens, and theSTRINGcheck now precedes the boolean-literal check. Bare reserved words (null,bool,true, …) are unaffected.2.
cddl2javaConsumes the AST directly, so it now generates
script.NullValuethe same way it already generates its sibling value types. PreviouslyNullValuewas the only discriminated*Valuetype with a settableObjectfield:3.
cddl2ts,cddl2py,cddl2swift,cddl2kotlinAll four special-cased any reference with
Value === 'null'and emitted the native null type, which intercepted the corrected string literal:In each generator the guard is narrowed to exclude string literals (
&& !isLiteralWithValue(t)), so a barenullreference (e.g.id: js-uint / null) still maps to the nullable/native type, while a quoted"null"now renders as the string literal. This is what retires the downstreamNULLABLE_DIFFERENCESworkaround.Tests
cddl/parser.test.ts: quoted reserved words parse as string literals; bare reserved words still resolve to native types / booleans.cddl2ts/cddl2py/cddl2swift/cddl2kotlintransform tests: explicit assertions that a quoted"null"renders as the string-literal type, while a barenullin a union stays nullable.webdriver-local/-remote), thecddl2javaNullValue.javafixture, and thecddl2ts/cddl2py/cddl2swift/cddl2kotlinsnapshots containingNullValue.cddl2tscli-examples (local.ts/remote.ts), nowScriptNullValue { type: "null" }.Full suite: 426 passed.