Mercurial Hosting > luan
changeset 1794:04ac5f2771c8
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 30 Dec 2023 18:41:35 -0700 |
parents | a55a891a4f67 |
children | 745f756e719b |
files | src/luan/modules/BasicLuan.java |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
diff -r a55a891a4f67 -r 04ac5f2771c8 src/luan/modules/BasicLuan.java --- a/src/luan/modules/BasicLuan.java Thu Dec 28 11:36:24 2023 -0700 +++ b/src/luan/modules/BasicLuan.java Sat Dec 30 18:41:35 2023 -0700 @@ -59,11 +59,17 @@ size = list.size(); } - @Override public Object[] call(Luan luan,Object[] args) { + @Override public Object[] call(Luan luan,Object[] args) throws LuanException { if( i >= size ) return LuanFunction.NOTHING; - Object val = list.get(i++); - return new Object[]{i,val}; + try { + Object val = list.get(i++); + return new Object[]{i,val}; + } catch(IndexOutOfBoundsException e) { + if( size != list.size() ) + throw new LuanException("list was modified during ipairs iteration"); + throw e; + } } @Override public boolean isImmutable() {