浏览代码

* 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/tw1755.pp svneol=native#text/plain
 tests/webtbs/tw17550.pp svneol=native#text/plain
 tests/webtbs/tw17550.pp svneol=native#text/plain
 tests/webtbs/tw1758.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/tw1765.pp svneol=native#text/plain
 tests/webtbs/tw1779.pp svneol=native#text/plain
 tests/webtbs/tw1779.pp svneol=native#text/plain
 tests/webtbs/tw1780.pp svneol=native#text/plain
 tests/webtbs/tw1780.pp svneol=native#text/plain

+ 6 - 1
compiler/ninl.pas

@@ -1711,7 +1711,12 @@ implementation
                       end;
                       end;
                     arraydef :
                     arraydef :
                       begin
                       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_array_of_const(left.resultdef) and
                            not is_dynamic_array(left.resultdef) then
                            not is_dynamic_array(left.resultdef) then
                           result:=cordconstnode.create(tarraydef(left.resultdef).highrange-
                           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.