sepcomp: initialize lazy guards to 'false' if opt_no_union_attribute.
authorJean Privat <jean@pryen.org>
Mon, 23 Mar 2015 14:16:26 +0000 (21:16 +0700)
committerJean Privat <jean@pryen.org>
Mon, 23 Mar 2015 15:28:34 +0000 (22:28 +0700)
Otherwise the guard is let at `NULL` (aka uninitialized) and will
ironically fail at runtime because the lazy guard is not initialized.

Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/separate_compiler.nit

index 424b849..00125ea 100644 (file)
@@ -2308,3 +2308,14 @@ redef class AMethPropdef
                return super
        end
 end
+
+redef class AAttrPropdef
+       redef fun init_expr(v, recv)
+       do
+               super
+               if is_lazy and v.compiler.modelbuilder.toolcontext.opt_no_union_attribute.value then
+                       var guard = self.mlazypropdef.mproperty
+                       v.write_attribute(guard, recv, v.bool_instance(false))
+               end
+       end
+end