Repository navigation
Conversation
FIX-LIST [SDK-TS-RESERVED-WORD-IDENTIFIERS], the TypeScript twin of [PY-SDK-GENERATED-KEYWORD-METHOD] (#9995). The TypeScript emitters wrote verb-table names unescaped where JavaScript binds a name: the facade's parameters (typed binding and generic door), the native client's interface parameters, the JSON-wire destructure, and the code-mode catalog's roots, bare verbs and self members. A reserved word there does not parse, and no PR-time job parses the generated TypeScript. - common.rs: JS_RESERVED_WORDS (ECMAScript reserved words, the strict-mode ones, arguments and eval), is_js_reserved and js_binding_name, which gives a reserved word a trailing underscore. - emit_ts.rs: js_binding_name at every binding position and at every use of that binding; a reserved wire field destructures as `field: field_`. Keys, property accesses and type members keep the name, which is legal. - catalog_fragment.rs: a root, bare verb or self member named by a reserved word is refused (GenerateError), since code mode calls it by that name. - tests: unit tests for the escape, the destructure entry and the catalog refusal; sdk_typescript_reserved_word_bindings scans the generated facade-verbs.ts, native-verbs.ts and catalog fragment for a reserved binding over the real verb table. Today's table names no reserved word at these positions, so no output changes.
|
Automatic reviews are disabled for this repository. Configure in Code Review Settings. |
|
Warning Review limit reached
This review includes 5 billable files and costs up to $1.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 50 minutes for your next included review. View limit details
|
…ember Review round 1 of #10011 (two P1s): - Suffixing could bind two inputs alike: fields `default` and `default_` both bound `default_`, and so did native arguments with those names. js_binding_names now allocates one binding list at a time: a name that binds as it is keeps it, and a reserved word, or a name the emitter binds or reads in that scope itself (`host`; `opts` with options; `rest`, `result` and the request in the JSON-wire block), takes `_`, then one more until no other name of the list has it. The facade parameters, generic-door parameters, wire destructure and native interface parameters each use it, and the call bodies reuse those bindings. The options and JSON-wire bodies now read the first parameter's binding rather than its raw row name. - In a type literal or interface, `new(...)` is a construct signature, not a method. A catalog leaf named `new` is now a property of its call type (`new: (input: ...) => ...`), and so is a native interface member `new` (ts_callable_member). The catalog readback still counts it. The whole-table scan also fails on a callable member named `new` in the native interface or the catalog. Today's table has no `new` segment and no argument or field named host, opts, rest or result, so no output changes. first_item lost its last caller and is removed.
Review round 2 of #10011: a JSON-wire field named `keyedJson` destructured into a binding of its own name, so the body's `keyedJson(...)` called the field string, not the imported helper. The same held for a parameter or field named `facadeCall`, `facadeClient`, `JSON` or `itemFromWire`. TS_BODY_READS lists every name a facade verb body reads beside its bindings (host, the two symbols, the key-value.js helpers, JSON). The three binding lists (typed binding parameters, the JSON-wire destructure, generic-door parameters) take them as fixed names, so such a name gets the trailing underscore. The unit tests use the emitter's own fixed lists; the whole-table scan also flags a facade binding that takes a body read, read from the generated file's value imports. Today's table names none, so the generated output does not change.
This branch has not been deployed
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
The TypeScript twin of #9995 (the generated Python SDK's
def continue, which broke the 21 Nov nightly e2e build). The TypeScript emitters write verb-table names unescaped at positions where JavaScript binds a name, and a reserved word there does not parse:facade-verbs.ts), and the values each body passes on;native-verbs.ts);const { <field>, ...rest } = request;selfmembers, declared asdeclare const,declare function,const,functionornamespace.No PR-time job parses the generated TypeScript, so a row with an argument named
default,deleteornewwould fail only at the nightly e2e. Today's table names no reserved word at any of these positions (checked over all 1601 rows), so no output changes.Change (crates/oneiron-sdk-generator)
src/generate/common.rs:JS_RESERVED_WORDS: ECMAScript's reserved words, the ones strict (module) code adds, andargumentsandeval, 48 names. Alsois_js_reserved, andjs_binding_names, which allocates the names of one binding list: a name binds as it is unless it is a reserved word or one of the list's fixed names; such a name takes a trailing underscore (default_, as fix(sdk-generator): escape Python hard keywords in namespace properties and parameters #9995 does for a Python keyword), and more until no other name of the list has it (defaultbesidedefault_bindsdefault__).ts_callable_memberwrites an interface or type-literal member namednewas a property of function type (new: (params) => result), sincenew(there opens a construct signature.src/generate/emit_ts.rs:js_binding_namesat every binding list (typed-binding and generic-door facade parameters, the JSON-wire destructure, native interface parameters), and each body reads those bindings. A facade list's fixed names areTS_BODY_READS, every name the verb body reads beside its bindings (host,facadeCall,facadeClient,JSON,keyedJson,itemFromWire), plusoptswith options, orrest,resultand the request in the JSON-wire block, so no field or parameter shadows the helper the call goes through. A renamed wire field destructures asdefault: default_, and the request is rebuilt from that binding. Object keys, property accesses (opts.default) and type members keep the name, which is legal there.src/catalog_fragment.rs: a root, bare verb orselfmember named by a reserved word is refused with aGenerateErrornaming the row. Code mode calls the verb by that name, so it cannot be renamed. A reserved word deeper in a path stays a member name (vault.exportworks as today).TypeScript contextual words (
type,declare,async,of) are valid binding names, so they stay. The Rust emitters need no change: cargo already rejects a reserved word there at PR time. Swift and Kotlin come from uniffi-bindgen, which quotes keywords.Tests
common::tests::js_binding_names_suffix_exactly_the_reserved_and_fixed_names,emit_ts::tests::a_reserved_wire_field_destructures_into_a_binding_of_its_own(with the emitter's own fixed names:keyedJson,JSON,host... are renamed),emit_ts::tests::a_facade_parameter_named_like_a_body_read_is_renamed,catalog_fragment::tests::a_reserved_word_binding_is_refused_and_a_reserved_member_stays(refusals fordelete,new.zz,self.default,self.let.zz,self.think.static;zz.deleteandself.zz.exportstay members; a leafzz.newis writtennew: (input: ...) => ...).crates/oneiron-sdk-generator/tests/sdk_typescript_reserved_word_bindings.rsruns the generator on the repository through its publicoutputsentry. It scansfacade-verbs.ts(parameter lists and destructures),native-verbs.ts(interface parameters) and the catalog fragment (declarations), and fails on any binding that is a reserved word, on a facade binding that takes a name the body reads (read from the generated file's value imports), and on a callable member namednew. It also pins its own parser on each form.cargo test --locked -p oneiron-sdk-generator --all-features --test sdk_typescript_reserved_word_bindingsopus-mainfix/proof-sdk-ts-reserved-red-r3(main 4317485 plus the catalog test and the scan test only): the catalog test is expected to fail ondelete, because main emitsdeclare function delete.--out-diroutput is expected to be byte-identical at main and at this head.Stored change
None. The generated SDK files are build outputs and are not checked in. No verb row changes.
FIX-LIST [SDK-TS-RESERVED-WORD-IDENTIFIERS].