Browse Source

* do not throw an internal error if an errorneous type is passed to str, resolves #37462

git-svn-id: trunk@45983 -
florian 5 years ago
parent
commit
f542ee7b92
3 changed files with 11 additions and 3 deletions
  1. 1 0
      .gitattributes
  2. 7 3
      compiler/ninl.pas
  3. 3 0
      tests/webtbf/tw37462.pp

+ 1 - 0
.gitattributes

@@ -16542,6 +16542,7 @@ tests/webtbf/tw37303.pp -text svneol=native#text/pascal
 tests/webtbf/tw3738.pp svneol=native#text/plain
 tests/webtbf/tw3738.pp svneol=native#text/plain
 tests/webtbf/tw3740.pp svneol=native#text/plain
 tests/webtbf/tw3740.pp svneol=native#text/plain
 tests/webtbf/tw37460.pp svneol=native#text/pascal
 tests/webtbf/tw37460.pp svneol=native#text/pascal
+tests/webtbf/tw37462.pp svneol=native#text/pascal
 tests/webtbf/tw3790.pp svneol=native#text/plain
 tests/webtbf/tw3790.pp svneol=native#text/plain
 tests/webtbf/tw3812.pp svneol=native#text/plain
 tests/webtbf/tw3812.pp svneol=native#text/plain
 tests/webtbf/tw3930a.pp svneol=native#text/plain
 tests/webtbf/tw3930a.pp svneol=native#text/plain

+ 7 - 3
compiler/ninl.pas

@@ -273,8 +273,12 @@ implementation
           end;
           end;
 
 
         { in case we are in a generic definition, we cannot
         { in case we are in a generic definition, we cannot
-          do all checks, the parameters might be type parameters }
-        if df_generic in current_procinfo.procdef.defoptions then
+          do all checks, the parameters might be type parameters,
+
+          bailout as well in case of an error before }
+        if (df_generic in current_procinfo.procdef.defoptions) or
+         (dest.resultdef.typ=errordef) or
+         (source.resultdef.typ=errordef) then
           begin
           begin
             result.Free;
             result.Free;
             result:=nil;
             result:=nil;
@@ -1477,7 +1481,7 @@ implementation
     begin
     begin
       ordtype := torddef(def).ordtype;
       ordtype := torddef(def).ordtype;
       if not (ordtype in [s64bit,u64bit,s32bit,u32bit,s16bit,u16bit,s8bit,u8bit]) then
       if not (ordtype in [s64bit,u64bit,s32bit,u32bit,s16bit,u16bit,s8bit,u8bit]) then
-        internalerror(2013032603);
+        internalerror(2020080101);
 
 
       if is_oversizedint(def) then
       if is_oversizedint(def) then
         begin
         begin

+ 3 - 0
tests/webtbf/tw37462.pp

@@ -0,0 +1,3 @@
+{ %fail }
+var a : string;
+begin str(1 > 1 > 1, a)