v
v copied to clipboard
C Error when compiling V with `println` or `dump` calls
V version: V 0.2.4 71d9871.1fdbdf4 OS: Arch linux
When I insert some println
call into the compiler it won't wont compile its self after the first run again.
e.g.
pub fn (t &Table) find_method_from_embeds(sym &TypeSymbol, method_name string) ?(Fn, []Type) {
if sym.info is Struct {
mut found_methods := []Fn{}
mut embed_of_found_methods := []Type{}
println(sym.info) // << inserted call
for embed in sym.info.embeds {
embed_sym := t.sym(embed)
// ...
after the first successful compile using v self
every run after that will fail with the following error (and also having correctly printed the sym.info
)
==================
/tmp/v_1000/v.9709905541096883223.tmp.c:29540: error: unrecognized character \x01
...
==================
The C file contains invalid characters and null bytes (that I can't paste into the issue, there are some at the end of the v__dotgraph__DotGraph_new_node
line) in a random spot.
void v__depgraph__show(v__depgraph__DepGraph* graph, string path) {
v__dotgraph__DotGraph* dg = v__dotgraph__new(_SLIT("ModGraph"), str_intp(2, _MOV((StrIntpData[]){{_SLIT("ModGraph for "), 0xfe10, {.d_s = path}}, {_SLIT0, 0, { .d_c = 0 }}})), _SLIT("blue"));
string mbuiltin = _SLIT("builtin");
for (int _t1 = 0; _t1 < graph->nodes.len; ++_t1) {
v__depgraph__DepGraphNode node = ((v__depgraph__DepGraphNode*)graph->nodes.data)[_t1];
bool is_main = string__eq(node.name, _SLIT("main"));
v__dotgraph__DotGraph_new_node(dg, node.name, (v__dotgraph__NewNodeConfig){.node_name = (string){.str=(byteptr)"", .is_lit=1},.should_highlight = is_main,.tooltip = (string){.str=(byteptr)"", .is_lit=1},.ctx = ((voidptr)(0)),.name2node_fn = �
Array_string deps = array_clone_to_depth(&node.deps, 0);
if (!string__eq(node.name, mbuiltin) && !Array_string_contains(deps, mbuiltin)) {
array_push((array*)&deps, _MOV((string[]){ string_clone(mbuiltin) }));
}
for (int _t3 = 0; _t3 < deps.len; ++_t3) {
string dep = ((string*)deps.data)[_t3];
v__dotgraph__DotGraph_new_edge(dg, node.name, dep, (v__dotgraph__NewEdgeConfig){.should_highlight = is_main,.ctx = ((voidptr)(0)),.name2node_fn = cfg
}
}
v__dotgraph__DotGraph_finish(dg);
I would expect the compiler to correctly compile.
Fixed. v self
compiles with this line added.
It is still failed when execute v self
again, the problem maybe in sym.info.fields
.