Skip to content

Add typed Map[K, V] with map literals and basic methods #35

@synapticvoid

Description

@synapticvoid

Task

Implement Map[K, V] as a built-in generic collection type.

Acceptance criteria

  • Type syntax: Map[Str, Int], Map[Str, Bool], etc.
  • Non-empty literal infers types: {"a": 1}Map[Str, Int]
  • Empty literal requires annotation: var m: Map[Str, Int] = {}
  • Mixed-type literals are a compile-time error
  • K must be hashable — compile-time error if not
  • Map is unordered; no iteration order guaranteed
  • Methods: len(), contains(key), get(key), get(key, default), add(key, value), remove(key)
  • Mutating methods (add, remove) require var receiver — compile-time error on const

Spec

See PDP-003: Collection Types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions