Skip to content

Commit d151411

Browse files
committed
Make updateAt safe
1 parent 4ac3e92 commit d151411

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Data/Array.purs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ foreign import updateAt
167167
"function updateAt (index) {\
168168
\ return function (a) {\
169169
\ return function (l) {\
170+
\ var i = ~~index;\
171+
\ if (i < 0 || i >= l.length) return l;\
170172
\ var l1 = l.slice();\
171-
\ l1[index] = a;\
173+
\ l1[i] = a;\
172174
\ return l1;\
173175
\ }; \
174176
\ };\

0 commit comments

Comments
 (0)