diff --git a/src/dev/flang/ast/InlineArray.java b/src/dev/flang/ast/InlineArray.java index 01f050698..e67be357b 100644 --- a/src/dev/flang/ast/InlineArray.java +++ b/src/dev/flang/ast/InlineArray.java @@ -119,7 +119,7 @@ AbstractType typeIfKnown() _elements.iterator()); _type = Types.t_ERROR; } - if (_type == null) + else { _type = t == null ? null : @@ -162,7 +162,7 @@ public Expr propagateExpectedType(Resolution res, AbstractFeature outer, Abstrac { e.propagateExpectedType(res, outer, elementType); } - _type = t; + _type = Types.resolved.f_array.resultTypeIfPresent(res, new List<>(elementType)); } } return this; @@ -181,7 +181,8 @@ private AbstractType elementType(AbstractType t) if (PRECONDITIONS) require (t != null); - if (t.featureOfType() == Types.resolved.f_array && + // NYI see issue: #1817 + if (Types.resolved.f_array.inheritsFrom(t.featureOfType()) && t.generics().size() == 1) { return t.generics().get(0); diff --git a/tests/reg_issue169_backward_type_propagation_array/Makefile b/tests/reg_issue169_backward_type_propagation_array/Makefile new file mode 100644 index 000000000..704c75f62 --- /dev/null +++ b/tests/reg_issue169_backward_type_propagation_array/Makefile @@ -0,0 +1,27 @@ +# This file is part of the Fuzion language implementation. +# +# The Fuzion language implementation is free software: you can redistribute it +# and/or modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, version 3 of the License. +# +# The Fuzion language implementation is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License along with The +# Fuzion language implementation. If not, see . + + +# ----------------------------------------------------------------------- +# +# Tokiwa Software GmbH, Germany +# +# Source code of Fuzion test Makefile +# +# Author: Fridtjof Siebert (siebert@tokiwa.software) +# +# ----------------------------------------------------------------------- + +override NAME = issue169 +include ../positive.mk diff --git a/tests/reg_issue169_backward_type_propagation_array/issue169.fz b/tests/reg_issue169_backward_type_propagation_array/issue169.fz new file mode 100644 index 000000000..b878127a8 --- /dev/null +++ b/tests/reg_issue169_backward_type_propagation_array/issue169.fz @@ -0,0 +1,16 @@ +issue169 => + + a array i32 := [] + b Sequence i32 := [] + c Sequence u8 := [] + d Sequence f32 := [0,1,2] + e Sequence (Sequence i16) := [[0,1],[2]] + # NYI does not work yet + # f := [u8 4, 3, 3] + + say (type_of a) + say (type_of b) + say (type_of c) + say (type_of d) + say (type_of e) + # say (type_of f)