8000 [BUG] Dict KeyElements with ImmutableOrigin doesn't work. · Issue #4717 · modular/modular · GitHub
[go: up one dir, main page]

Skip to content
[BUG] Dict KeyElements with ImmutableOrigin doesn't work. #4717
@sibarras

Description

@sibarras

Bug description

Actual behavior

Dict is complaining saying that we are trying to write to a place readable by another argument. It's not true. Could be an origin issue in the Dict._find_ref who tries to get the origin from the underlying optional value.

Expected behavior

Should not complain because we are not replacing or modifying the key in any case.

Steps to reproduce

fn some_test() raises:
    some_str = String("hello,world")  # simple string
    slice = StringSlice(some_str)  # create an slice with an immutable origin
    parts = slice.split(",")
    dct = Dict[__type_of(slice).Immutable, Int]()
    for part in parts:
        dct[part] # Do not fail but it's unusable. Try to assign it to something and will fail
        dct[part] = 0 # argument of '__setitem__' call allows writing a memory location previously readable through another aliased argument
        dct.setdefault(part, 0) # argument of '__setitem__' call allows writing a memory location previously readable through another aliased argument
        dct.get(part, 0) # argument of '__setitem__' call allows writing a memory location previously readable through another aliased argument

System information

   Pixi version: 0.47.0
       Platform: linux-64

Virtual packages: __unix=0=0
: __linux=6.6.87.1=0
: __glibc=2.35=0
: __cuda=12.6=0
: __archspec=1=skylake

Package Version Build Size Kind Source
max 25.4.0.dev2025052905 release 9.2 KiB conda https://conda.modular.com/max-nightly/
max-core 25.4.0.dev2025052905 release 211.7 MiB conda https://conda.modular.com/max-nightly/
max-python 25.4.0.dev2025052905 release 13.9 MiB conda https://conda.modular.com/max-nightly/

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmodular-repomojoIssues that are related to mojo

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0