Commit bf9fc6e
authored
feat: toNumeric and checkNumeric (#173)
* feat: add pushNumeric, toNumeric and checkNumeric
These functions rely (lightly) on Zig's comptime to minimize some of the
annoying overhead of writing `@intCast` and `@floatCast` all the time by
making those builtins part of the function definition. However, since
those builtins assert in builds with runtime safety enabled, these
functions will crash the program if called with bad Lua input. More
discussion is warranted about the tradeoffs of going this route before
merging.
Resolves #172.
* fix: remove pushNumeric
* fix: checkNumeric raises a lua error
* fix: toNumeric raises a Zig error
* fix: remove pushNumeric from test, typo in toNumeric
* fix: error.IntegerCastFailed -> error.Overflow
* fix: add test for checkNumeric
* fix: error message inconsistency outside of test control
* fix: toStringEx not available in 5.11 parent ef5af10 commit bf9fc6e
2 files changed
+77
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2594 | 2594 | | |
2595 | 2595 | | |
2596 | 2596 | | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
2597 | 2610 | | |
2598 | 2611 | | |
2599 | 2612 | | |
| |||
3342 | 3355 | | |
3343 | 3356 | | |
3344 | 3357 | | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
3345 | 3384 | | |
3346 | 3385 | | |
3347 | 3386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3055 | 3055 | | |
3056 | 3056 | | |
3057 | 3057 | | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
| 3061 | + | |
| 3062 | + | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
| 3071 | + | |
| 3072 | + | |
| 3073 | + | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
0 commit comments