native icon indicating copy to clipboard operation
native copied to clipboard

[record_use] Correctness: Support non-string map keys

Open dcharkes opened this issue 1 month ago • 0 comments

The current JSON structure for package:record_use only supports string keys for MapConstant objects. The keys are serialized directly as strings, while the values are normalized as indices into the constants array. This limits the ability to represent const maps that use other constant types (e.g., int, bool, or other objects) as keys.

Current Format:

{
  "type": "map",
  "value": {
    "key1": 3 
  }
}

Proposed Format options:

{
  "type": "map",
  "value": {
    "1": 3,
    "2": 4
  }
}
{
  "type": "map",
  "value": [
    { "key": 1, "value": 3 },
    { "key": 2, "value": 4 },
  ]
}

Note that this does not allow for an efficient JSON view with https://github.com/dart-lang/native/issues/2681, so the map keys need to be eagerly looked up from the constants array on building the view.

dcharkes avatar Oct 20 '25 09:10 dcharkes