Skip to content

get value from optional array #22490

@esquerbatua

Description

@esquerbatua

Describe the bug

With an optional map, when try to get a value, throws a C error

Reproduction Steps

struct OptionalMap {
    opmap ?map[string]f64
}

fn main() {
    op := OptionalMap{}
    assert (op.opmap["1"] or { 0 }) == 0.0

    op2 := OptionalMap{opmap: {"1": 1.0}}
    assert op2.opmap["1"] == 1.0
}

Expected Behavior

Runs correctly without errors

Current Behavior

error: cannot convert 'struct _option_Map_string_f64' to 'int'

Possible Solution

No response

Additional Information/Context

No response

V version

V full version: V 0.4.8 469b56e.5aa6eaf

Environment details (OS name and version, etc.)

V full version: V 0.4.8 469b56e.5aa6eaf
OS: linux, Ubuntu 24.04.1 LTS
Processor: 16 cpus, 64bit, little endian, AMD Ryzen 7 7840HS w/ Radeon 780M Graphics

vexe: /home/esquerbatua/git/v/v
vexe mtime: 2024-10-11 13:45:30

vroot: OK, value: /home/esquerbatua/git/v
VMODULES: OK, value: /home/esquerbatua/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.43.0
Git vroot status: weekly.2024.41-14-g5aa6eaf3
.git/config present: true

CC version: cc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
thirdparty/tcc status: thirdparty-linux-amd64 0134e9b9

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

Labels

BugThis tag is applied to issues which reports bugs.Unit: CheckerBugs/feature requests, that are related to the type checker.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions