Re: Confusing error message for nil-indexed C arrays

  • From: Markus Walther <dr.marikos@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sat, 4 Aug 2012 03:26:34 +0200

On Fri, Aug 3, 2012 at 11:31 PM, Mike Pall <mike-1208@xxxxxxxxxx> wrote:
> Markus Walther wrote:
>> > local array = (require 'ffi').new('int[?]',1) ; array[nil] = 1;
>> stdin:1: 'int [?]' cannot be indexed
>> [...]
>> Q: Could we have something like "'int[?]' index is nil" instead?
> Well, the error is generic. What if you index an array with e.g.
> 'true' or a table as a key? Would it help to use
>   '%s' cannot be indexed with '%s'
> e.g.
>   'int [?]' cannot be indexed with 'nil'
> instead?

Yes, I think that would be helpful - assuming the 2nd '%s' is
instantiated with the type or tostring  of the offending index value.
Precisely because it supplies information that often cannot be
inferred by glancing at the source. For sure, it would have provided
me with the right clue for my bug.

Thanks, Markus

Bond: "Everybody needs a hobby." Villain: "What's yours?" Bond: "Resurrection."

(007: Skyfall Trailer,

Other related posts: