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
encode(val.$method()) // Problem here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!11!
Reproduction Steps
structHuman {
name string
}
enumAnimal {
dog
cat
}
typeEntity= Animal | Human
@[sumtype_to: Animal]
fn (ent Entity) json_cast_to_animal() Animal {
return ent asAnimal
}
@[sumtype_to: Human]
fn (ent Entity) json_cast_to_human() Human {
return ent asHuman
}
fnencode[T](val T) {
$if T is $sumtype {
$for method in T.methods {
if method.attrs.len >=1 {
if method.attrs[0].contains('sumtype_to') {
if val.type_name() == method.attrs[0].all_after('sumtype_to:').trim_space() {
println(val.$method())
encode(val.$method()) // Problem here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!11!
}
}
}
}
} $else {
// error('cannot encode value with ${typeof(val).name} type')
}
}
encode(Entity(Human{'Monke'}))
encode(Entity(Animal.cat))
Expected Behavior
Human{
name: 'Monke'
}
cat
Current Behavior
==================
/tmp/v_1000/copy.8521023635428838776.tmp.c:15353: error: cannot convert 'enum <anonymous>' 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
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.3 be51143
Environment details (OS name and version, etc.)
Linux Ubuntu
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:
Describe the bug
encode(val.$method()) // Problem here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!11!
Reproduction Steps
Expected Behavior
Human{ name: 'Monke' } cat
Current Behavior
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.3 be51143
Environment details (OS name and version, etc.)
Linux Ubuntu
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: