You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structStructType[T] {
mut:
val T
}
typeSumTypes= StructType[string] | []SumTypes | []string|bool|int|stringpubstructCount {
mut:
total int
}
// count_chars count json sizen whithout new encodepub fn (mut count Count) count_chars[T](val T) {
$if T is $sumtype {
$for v in val.variants {
if val isv {
// dump(typeof(val).name)
count.count_chars(val)
}
}
} $else$if T is $struct {
count.chars_in_struct(val)
} $else {
}
}
// chars_in_structfn (mut count Count) chars_in_struct[T](val T) {
$for field in T.fields {
va:= val.$(field.name)
count.count_chars(va) // Not works
count.count_chars(val.$(field.name)) // Not works
}
}
fnmain() {
mutcount:= Count{}
count.count_chars(StructType[SumTypes]{ val: '' })
println('ok')
asserttrue
}
Expected Behavior
assert pass, print ok
Current Behavior
==================
/tmp/v_1000/a.01HRM75XMWA9WKHPFBFAQVD0EY.tmp.c:13325: error: cannot convert 'struct main__SumTypes' to 'struct string'
...
==================
(Use `v -cg` to print the entire error message)
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
Describe the bug
Reproduction Steps
Expected Behavior
assert pass, print ok
Current Behavior
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.4 386bd77
Environment details (OS name and version, etc.)
Linux
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.
The text was updated successfully, but these errors were encountered: