lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Duboucher Thomas a écrit :
> Roberto Ierusalimschy a écrit :
>> This bug is caused by a really dirty trick. Lua are using the third
>> letter of the type name to distinguish between type names.
>> "number" and "nil" crash on the first letter, "number" and "function"
>> crash on the second; but "string" and "thread" crash on the third.
> 
>> (Yes, I know, this was a really dirty trick...)
> 
>> -- Roberto
> 
> 
> 	Another question
> $> print(C)
> 	Why is C referred as a 'thread' instead of a coroutine in the error
> message? :)
> 
> 	Thomas

Also, in ldebug.c, why not replace

int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) {
  const char *t1 = luaT_typenames[ttype(p1)];
  const char *t2 = luaT_typenames[ttype(p2)];
  if (t1[2] == t2[2])
    luaG_runerror(L, "attempt to compare two %s values", t1);
  else
    luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
  return 0;
}

by something more like

int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) {
  int t1 = ttype(p1);
  int t2 = ttype(p2);
  if (t1 == t2)
    luaG_runerror(L, "attempt to compare two %s values",
luaT_typenames[t1]);
  else
    luaG_runerror(L, "attempt to compare %s with %s",
luaT_typenames[t1], luaT_typenames[t2]);
  return 0;
}

or did I miss something? :)

	Thomas.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktLdJ4ACgkQBV7eXqefhqhoUACfb0mPTHLXEy1jHrarzF9GpaPk
b3YAn1pi1zDoJ/LOXqaHRLFjDfMxBmlA
=EIPF
-----END PGP SIGNATURE-----