A-ha! Managed to get Duktape debug working with a #define DUK_USE_DPRINT.
Don't really understand the output though, and there's a ton of it.
Line 57817 of duktape.c: (duk_js_compiler.c:442)
if (expect >= 0 && comp_ctx->curr_token.t != expect) {
DUK_D(DUK_DPRINT("parse error: expect=%ld, got=%ld",
(long) expect, (long) comp_ctx->curr_token.t));
DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR);
}
expect=50, curr_token.t=1
Hmm, I run it again with DUK_USE_DDPRINT and it fails in a different place. I think this might be Duktape memory being trashed, and as it happened to Artur with clib2 too, maybe it is clib trashing memory?