diff options
| author | Mike Pall <mike> | 2012-08-05 17:26:01 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2012-08-05 17:26:01 +0200 |
| commit | 806822b70b0b302649738e78f8a6a59154ca8101 (patch) | |
| tree | 30ba5c73d8de4daad89a0e2c1e4a3bd06c79d3ae /src | |
| parent | 0a750fe71522c64b8a5e2b1c7fe926e3c4098a86 (diff) | |
| download | luajit-806822b70b0b302649738e78f8a6a59154ca8101.tar.gz luajit-806822b70b0b302649738e78f8a6a59154ca8101.tar.bz2 luajit-806822b70b0b302649738e78f8a6a59154ca8101.zip | |
FFI: Improve error message for bad indexing attempts.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib_ffi.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib_ffi.c b/src/lib_ffi.c index 5cb9086e..e0951c56 100644 --- a/src/lib_ffi.c +++ b/src/lib_ffi.c | |||
| @@ -112,10 +112,14 @@ static int ffi_index_meta(lua_State *L, CTState *cts, CType *ct, MMS mm) | |||
| 112 | const char *s; | 112 | const char *s; |
| 113 | err_index: | 113 | err_index: |
| 114 | s = strdata(lj_ctype_repr(L, id, NULL)); | 114 | s = strdata(lj_ctype_repr(L, id, NULL)); |
| 115 | if (tvisstr(L->base+1)) | 115 | if (tvisstr(L->base+1)) { |
| 116 | lj_err_callerv(L, LJ_ERR_FFI_BADMEMBER, s, strVdata(L->base+1)); | 116 | lj_err_callerv(L, LJ_ERR_FFI_BADMEMBER, s, strVdata(L->base+1)); |
| 117 | else | 117 | } else { |
| 118 | lj_err_callerv(L, LJ_ERR_FFI_BADIDX, s); | 118 | const char *key = tviscdata(L->base+1) ? |
| 119 | strdata(lj_ctype_repr(L, cdataV(L->base+1)->ctypeid, NULL)) : | ||
| 120 | lj_typename(L->base+1); | ||
| 121 | lj_err_callerv(L, LJ_ERR_FFI_BADIDXW, s, key); | ||
| 122 | } | ||
| 119 | } | 123 | } |
| 120 | if (!tvisfunc(tv)) { | 124 | if (!tvisfunc(tv)) { |
| 121 | if (mm == MM_index) { | 125 | if (mm == MM_index) { |
