1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v.parser, v.checker, v.gen: add support for [translated] tag (#13373)

This commit is contained in:
div72
2022-02-06 01:16:02 +03:00
committed by GitHub
parent 054c8b1f13
commit cec7e91714
18 changed files with 82 additions and 65 deletions

View File

@@ -313,7 +313,7 @@ pub fn (mut c Checker) struct_init(mut node ast.StructInit) ast.Type {
}
if obj.is_stack_obj && !c.inside_unsafe {
sym := c.table.sym(obj.typ.set_nr_muls(0))
if !sym.is_heap() && !c.pref.translated {
if !sym.is_heap() && !c.pref.translated && !c.file.is_translated {
suggestion := if sym.kind == .struct_ {
'declaring `$sym.name` as `[heap]`'
} else {
@@ -348,7 +348,7 @@ pub fn (mut c Checker) struct_init(mut node ast.StructInit) ast.Type {
continue
}
if field.typ.is_ptr() && !field.typ.has_flag(.shared_f) && !node.has_update_expr
&& !c.pref.translated {
&& !c.pref.translated && !c.file.is_translated {
c.error('reference field `${type_sym.name}.$field.name` must be initialized',
node.pos)
}