diff core/src/luan/impl/LenExpr.java @ 404:d55e873e1f0d

metatables now only apply to tables
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 29 Apr 2015 07:04:40 -0600
parents 3dcb0f9bee82
children d9df6d6cb927
line wrap: on
line diff
--- a/core/src/luan/impl/LenExpr.java	Tue Apr 28 22:49:33 2015 -0600
+++ b/core/src/luan/impl/LenExpr.java	Wed Apr 29 07:04:40 2015 -0600
@@ -25,13 +25,12 @@
 			return a.length;
 		}
 		LuanBit bit = luan.bit(se);
-		LuanFunction fn = bit.getHandlerFunction("__len",o);
+		if( !(o instanceof LuanTable) )
+			throw bit.exception( "attempt to get length of a " + Luan.type(o) + " value" );
+		LuanTable t = (LuanTable)o;
+		LuanFunction fn = bit.getHandlerFunction("__len",t);
 		if( fn != null )
 			return Luan.first(bit.call(fn,"__len",new Object[]{o}));
-		if( o instanceof LuanTable ) {
-			LuanTable t = (LuanTable)o;
-			return t.length();
-		}
-		throw bit.exception( "attempt to get length of a " + Luan.type(o) + " value" );
+		return t.length();
 	}
 }