From 7b720228a4f68672595bdd588789768f9b4e564e Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 4 May 2016 10:25:50 -0400 Subject: [PATCH] nitc/engines: do not initialize optional attributes on the allocation Signed-off-by: Jean Privat --- src/compiler/abstract_compiler.nit | 2 +- src/interpreter/naive_interpreter.nit | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 9982dd1..9811228 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -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 diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index 99f2356..539fb89 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -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) -- 1.7.9.5