Skip to content

Commit 1a111dd

Browse files
committedApr 17, 2018
atg. green 1993. zero() arrays with typ() instead of typ.zero(). fixes #47
1 parent 446afbc commit 1a111dd

File tree

3 files changed

+646
-641
lines changed

3 files changed

+646
-641
lines changed
 

‎pkg/compiler/prelude/prelude.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function __gi_GetRangeCheck(x, i)
1919
end;
2020

2121
function __gi_SetRangeCheck(x, i, val)
22-
--print("SetRangeCheck. x=", __st(x), " i=", i, " val=", val)
22+
--print("SetRangeCheck. x=".. __st(x) .." i="..tostring(i).." val=", val)
2323
if x == nil or i < 0 or i >= #x then
2424
error("index out of range; i="..tostring(i)..". #x is "..tostring(#x))
2525
end

‎pkg/compiler/prelude/tsys.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,12 @@ __newType = function(size, kind, str, named, pkg, exported, constructor)
19391939

19401940
typ.zero = function()
19411941
--print("in zero() for array...")
1942-
return __newAnyArrayValue(typ.elem, typ.len)
1942+
1943+
local array = {}
1944+
for i =0, typ.len -1 do
1945+
array[i]= typ.elem();
1946+
end
1947+
return array;
19431948
end;
19441949

19451950
elseif kind == __kindStruct then

‎pkg/compiler/prelude_static.go

+639-639
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.