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
modulemainimportstringspubstructMyStruct[T] {
pubmut:
result T
id string
}
fnmain() {
x:= MyStruct[int]{}
y:= MyStruct[string]{}
dump(x.indent_str())
dump(y.indent_str())
}
pub fn (it MyStruct[T]) indent_str[T]() string {
mutres:= strings.new_builder(128)
res.write_string('${it.result}')
// following is OK// res.writeln('${it.result}')return res.str()
}
v g.v
Expected Behavior
compile ok
Current Behavior
$ v g.v
================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/g.01KBMWV9MNPR8A6ZW47790YW53.tmp.c:5033: error: cannot convert 'struct string' to 'long'
=================================================================
Try passing `-g` when compiling, to see a .v file:line information, that correlates more with the C error.
(Alternatively, pass `-show-c-output`, to print the full C error message).
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
Possible Solution
use writeln instead of write_string, it will pass compile
Describe the bug
generic T function may fail with
strings.write_stringbut notstrings.writeln.found by PR #25857
Reproduction Steps
g.v
Expected Behavior
compile ok
Current Behavior
Possible Solution
use
writelninstead ofwrite_string, it will pass compileAdditional Information/Context
No response
V version
V 0.4.12 dafa6fd
Environment details (OS name and version, etc.)
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.