{{ message }}
fix(dart): reserve the MapEntry runtime name - #3475
Merged
Merged
Conversation
A model class named MapEntry shadows dart:core's MapEntry, which the generated EnumValues<T> helper uses, so the output does not compile. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

A JSON input with a
MapEntryproperty makes quicktype emit a Dart class namedMapEntry, shadowingdart:core's. The generatedEnumValues<T>helper callsMapEntry(v, k), so the file fails to compile:TopLevel.dart:6504:52: Error: Too many positional arguments: 0 allowed, but 2 found. ... reverseMap = map.map((k, v) => MapEntry(v, k));. ReservingMapEntryin the Dart keyword list renames the model class instead.Coverage:
MapEntryadded totest/keywords.txt, withtest/inputs/json/priority/keywords.json,test/inputs/schema/keyword-enum.schemaandtest/inputs/schema/keyword-unions.schemaregenerated bytest/make-keyword-tests.sh. These are shared inputs, so all languages that run them now exercise the name.Validation:
npm run build;CPUs=2 QUICKTEST=true FIXTURE=dart npm run test:fixtures(68 tests, all Dart option variants);CPUs=2 QUICKTEST=true FIXTURE=schema-dart npm run test:fixtures -- test/inputs/schema/keyword-enum.schema test/inputs/schema/keyword-unions.schema;keywords.jsonthroughtypescript, javascript, typescript-zod, typescript-effect-schema, swift, golang, rust, kotlin, kotlin-jackson, cplusplus, objective-c, php, elixir, elm, crystal, pike, flow, javascript-prop-types, python, ruby, csharp, java;npm run lint. Baseline without theconstants.tschange reproduces the compile error above.Production change: 1 line added, 0 removed.
🤖 Generated with Claude Code