V version: V 0.1.24 51222ba
OS: Void linux(glibc)
What did you do?
module main
fn main() {
n := 123 as string
println(n)
}
What did you expect to see?
123
What did you see instead?
/tmp/v/test2.tmp.c: In function 'main__main':
/tmp/v/test2.tmp.c:3915:1: error: conversion to non-scalar type requested
3915 | string n=(string)( 123 ) ;
| ^~~~~~
V error: C error. This should never happen.
Please create a GitHub issue: https://github.com/vlang/v/issues/new/choose
I'll be leaving this open until we get a better error message but what you are looking for is probably 123.str()
@lutherwenxu do we really need to do that? as casting was added and removed immediately. If you meant that should give an error message as casting is only for sum types or a similar to it then I don't think it's needed.
I just mean ANY V error would work. It just shouldn't result in a C error.
Fixed:
`as` casts have been removed, use the old syntax: `Type(val)`