nitc/engines: do not initialize optional attributes on the allocation
authorJean Privat <jean@pryen.org>
Wed, 4 May 2016 14:25:50 +0000 (10:25 -0400)
committerJean Privat <jean@pryen.org>
Wed, 4 May 2016 14:25:50 +0000 (10:25 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/abstract_compiler.nit
src/interpreter/naive_interpreter.nit

index 9982dd1..9811228 100644 (file)
@@ -3162,7 +3162,7 @@ redef class AAttrPropdef
 
        fun init_expr(v: AbstractCompilerVisitor, recv: RuntimeVariable)
        do
-               if has_value and not is_lazy and not n_expr isa ANullExpr then evaluate_expr(v, recv)
+               if has_value and not is_lazy and not is_optional and not n_expr isa ANullExpr then evaluate_expr(v, recv)
        end
 
        # Evaluate, store and return the default value of the attribute
index 99f2356..539fb89 100644 (file)
@@ -1514,7 +1514,7 @@ redef class AAttrPropdef
        # Evaluate and set the default value of the attribute in `recv`
        private fun init_expr(v: NaiveInterpreter, recv: Instance)
        do
-               if is_lazy then return
+               if is_lazy or is_optional then return
                if has_value then
                        var f = v.new_frame(self, mreadpropdef.as(not null), [recv])
                        evaluate_expr(v, recv, f)