feat: raise max method parameters from 10 to 16 with proper error handling

Add MAX_PARAMETERS constant set to 16 and extend VM bytecode instructions CODE_CALL_11 through CODE_CALL_16 to support the new limit. Introduce compile-time error messages when parameter or argument count exceeds 16 in function definitions, method declarations, subscript calls, and regular method calls. Add new native fiber call stubs fn_call9 through fn_call16 and register them in the core initialization. Include comprehensive test coverage for 9-16 parameter functions and methods, plus error tests for exceeding the limit in all contexts.
This commit is contained in:
Bob Nystrom
2013-11-29 23:08:27 +00:00
parent 1b3b50374f
commit 230017a616
10 changed files with 123 additions and 5 deletions
+24
View File
@@ -24,3 +24,27 @@ io.write(f7.call(1, 2, 3, 4, 5, 6, 7)) // expect: 28
var f8 = fn(a, b, c, d, e, f, g, h) a + b + c + d + e + f + g + h
io.write(f8.call(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
var f9 = fn(a, b, c, d, e, f, g, h, i) a + b + c + d + e + f + g + h + i
io.write(f9.call(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
var f10 = fn(a, b, c, d, e, f, g, h, i, j) a + b + c + d + e + f + g + h + i + j
io.write(f10.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
var f11 = fn(a, b, c, d, e, f, g, h, i, j, k) a + b + c + d + e + f + g + h + i + j + k
io.write(f11.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
var f12 = fn(a, b, c, d, e, f, g, h, i, j, k, l) a + b + c + d + e + f + g + h + i + j + k + l
io.write(f12.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
var f13 = fn(a, b, c, d, e, f, g, h, i, j, k, l, m) a + b + c + d + e + f + g + h + i + j + k + l + m
io.write(f13.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
var f14 = fn(a, b, c, d, e, f, g, h, i, j, k, l, m, n) a + b + c + d + e + f + g + h + i + j + k + l + m + n
io.write(f14.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
var f15 = fn(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) a + b + c + d + e + f + g + h + i + j + k + l + m + n + o
io.write(f15.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
var f16 = fn(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p
io.write(f16.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
+1
View File
@@ -0,0 +1 @@
var f = fn(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) { "!" } // expect error