mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ci: fix failing ./v vlib/builtin/builtin_test.v
(globals initialisation)
This commit is contained in:
parent
ed43bfc469
commit
dc1b54c669
@ -151,7 +151,9 @@ fn (mut g Gen) final_gen_str(typ StrType) {
|
|||||||
g.gen_str_for_thread(sym.info, styp, str_fn_name)
|
g.gen_str_for_thread(sym.info, styp, str_fn_name)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
verror('could not generate string method `$str_fn_name` for type `$styp`')
|
if sym.name != 'nil' {
|
||||||
|
verror('could not generate string method `$str_fn_name` for type `$styp`')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4709,10 +4709,21 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if field.has_expr || cinit {
|
if field.has_expr || cinit {
|
||||||
|
// `__global x = unsafe { nil }` should still use the simple direct initialisation, `g_main_argv` needs it.
|
||||||
|
mut is_simple_unsafe_expr := false
|
||||||
|
if field.expr is ast.UnsafeExpr {
|
||||||
|
if field.expr.expr is ast.Nil {
|
||||||
|
is_simple_unsafe_expr = true
|
||||||
|
}
|
||||||
|
if field.expr.expr.is_literal() {
|
||||||
|
is_simple_unsafe_expr = true
|
||||||
|
}
|
||||||
|
}
|
||||||
if g.pref.translated {
|
if g.pref.translated {
|
||||||
def_builder.write_string(' = ${g.expr_string(field.expr)}')
|
def_builder.write_string(' = ${g.expr_string(field.expr)}')
|
||||||
} else if (field.expr.is_literal() && should_init) || cinit
|
} else if (field.expr.is_literal() && should_init) || cinit
|
||||||
|| (field.expr is ast.ArrayInit && (field.expr as ast.ArrayInit).is_fixed) {
|
|| (field.expr is ast.ArrayInit && (field.expr as ast.ArrayInit).is_fixed)
|
||||||
|
|| is_simple_unsafe_expr {
|
||||||
// Simple literals can be initialized right away in global scope in C.
|
// Simple literals can be initialized right away in global scope in C.
|
||||||
// e.g. `int myglobal = 10;`
|
// e.g. `int myglobal = 10;`
|
||||||
def_builder.write_string(' = ${g.expr_string(field.expr)}')
|
def_builder.write_string(' = ${g.expr_string(field.expr)}')
|
||||||
|
Loading…
Reference in New Issue
Block a user