瀏覽代碼

* improve conversion of array constructor to set so that it behaves as if done inside pass_typecheck

git-svn-id: trunk@41843 -
svenbarth 6 年之前
父節點
當前提交
156b25501d
共有 1 個文件被更改,包括 19 次插入1 次删除
  1. 19 1
      compiler/ncnv.pas

+ 19 - 1
compiler/ncnv.pas

@@ -1653,7 +1653,25 @@ implementation
         left:=nil;
         { create a set constructor tree }
         arrayconstructor_to_set(hp);
-        result:=hp;
+        if is_emptyset(hp) then
+          begin
+            { enforce the result type for an empty set }
+            hp.resultdef:=resultdef;
+            result:=hp;
+          end
+        else if hp.resultdef<>resultdef then
+          begin
+            { the set might contain a subrange element (e.g. through a variable),
+              thus we need to insert another type conversion }
+            if nf_explicit in flags then
+              result:=ctypeconvnode.create_explicit(hp,totypedef)
+            else if nf_internal in flags then
+              result:=ctypeconvnode.create_internal(hp,totypedef)
+            else
+              result:=ctypeconvnode.create(hp,totypedef);
+          end
+        else
+          result:=hp;
       end;