Skip to content

checker: optional value in maps not allowed #26235

@enghitalo

Description

@enghitalo

Describe the bug

https://discord.com/channels/592103645835821068/592114487759470596/1455227013509021771

Reproduction Steps

module main

fn main() {
    a := map[string]?int{}
    println(a['abcd'] or { none })
    assert a['abcd'] or { none } == none
}

Expected Behavior

assert pass

Current Behavior

code.v:5:28: error: `or` block must provide a value of type `int`, not `none`
    3 | fn main() {
    4 |     a := map[string]?int{}
    5 |     println(a['abcd'] or { none })
      |                            ~~~~
    6 |     assert a['abcd'] or { none } == none
    7 | }
code.v:6:27: error: `or` block must provide a value of type `int`, not `none`
    4 |     a := map[string]?int{}
    5 |     println(a['abcd'] or { none })
    6 |     assert a['abcd'] or { none } == none
      |                           ~~~~
    7 | }

Possible Solution

No response

Additional Information/Context

No response

V version

latest

Environment details (OS name and version, etc.)

all

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions