Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to assign an Option/none in map[string]?string #18806

Closed
Ddiidev opened this issue Jul 7, 2023 · 0 comments · Fixed by #18813
Closed

Failed to assign an Option/none in map[string]?string #18806

Ddiidev opened this issue Jul 7, 2023 · 0 comments · Fixed by #18813
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@Ddiidev
Copy link
Contributor

Ddiidev commented Jul 7, 2023

Describe the bug

Code: https://vosca.dev/p/2e4ea06fa8

f := fn (s ?string) ?string {
	return s
}

mut data := map[string]?string{}
// ERROR!!
data = {
	'name': ?string('andre')
	'age': ?string('')
}


// ERROR!!
// data = {
// 	'name': ?string('andre')
// 	'age': ?string(none)
// }

// Apparently works with windowless TCC
// data = {
// 	'name': f('andre')
// 	'age': f(none)
// }

dump(data)

Expected Behavior

data: {
  name: Option('andre')
  age: Option('')
}

Current Behavior

Output:

code.v:1:1: warning: unused variable: `f`
    1 | f := fn (s ?string) ?string {
      | ^
    2 |     return s
    3 | }
/tmp/v_60000/code.2308165315178286467.tmp.c:2137: error: cannot convert 'struct _option_string' to 'unsigned char *'
builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Exited with error status 1

Reproduction Steps

https://vosca.dev/p/2e4ea06fa8

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.3.4 fc4c431.45f16a2

Environment details (OS name and version, etc.)

V full version: V 0.4.0 fc4c431.ded6c38
OS: linux, Ubuntu 22.04.2 LTS
Processor: 2 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz

getwd: /home/pmakhnev/playground
vexe: /home/pmakhnev/v/v
vexe mtime: 2023-07-07 00:00:17

vroot: OK, value: /home/pmakhnev/v
VMODULES: OK, value: /root/.vmodules
VTMP: OK, value: /tmp/v_0

Git version: git version 2.34.1
Git vroot status: weekly.2023.27-29-gded6c380
.git/config present: true

CC version: cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3
@Ddiidev Ddiidev added the Bug This tag is applied to issues which reports bugs. label Jul 7, 2023
@Ddiidev Ddiidev changed the title Failed to name a map[string]?string Failed to assign an Option/none in map[string]?string Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant