Преглед изворни кода

* fixed evaluation of length('') (the type of an empty string is a chararray
instead of string) (mantis #17604)

git-svn-id: trunk@16128 -

Jonas Maebe пре 15 година
родитељ
комит
a178ff5172
3 измењених фајлова са 12 додато и 1 уклоњено
  1. 1 0
      .gitattributes
  2. 6 1
      compiler/ninl.pas
  3. 5 0
      tests/webtbs/tw17604.pp

+ 1 - 0
.gitattributes

@@ -10701,6 +10701,7 @@ tests/webtbs/tw1754c.pp svneol=native#text/plain
 tests/webtbs/tw1755.pp svneol=native#text/plain
 tests/webtbs/tw17550.pp svneol=native#text/plain
 tests/webtbs/tw1758.pp svneol=native#text/plain
+tests/webtbs/tw17604.pp svneol=native#text/plain
 tests/webtbs/tw1765.pp svneol=native#text/plain
 tests/webtbs/tw1779.pp svneol=native#text/plain
 tests/webtbs/tw1780.pp svneol=native#text/plain

+ 6 - 1
compiler/ninl.pas

@@ -1711,7 +1711,12 @@ implementation
                       end;
                     arraydef :
                       begin
-                        if not is_open_array(left.resultdef) and
+                        if (left.nodetype=stringconstn) then
+                          begin
+                            result:=cordconstnode.create(
+                              tstringconstnode(left).len,sinttype,true);
+                          end
+                        else if not is_open_array(left.resultdef) and
                            not is_array_of_const(left.resultdef) and
                            not is_dynamic_array(left.resultdef) then
                           result:=cordconstnode.create(tarraydef(left.resultdef).highrange-

+ 5 - 0
tests/webtbs/tw17604.pp

@@ -0,0 +1,5 @@
+program TestLength;
+begin 
+  if Length('') <> 0 then
+    halt(1);
+end.