mirror of
https://github.com/janet-lang/janet
synced 2024-12-27 17:00:27 +00:00
Ensure value is of specified type or panic
This commit is contained in:
parent
939d1dcae9
commit
97a8938407
@ -958,9 +958,14 @@ JANET_CORE_FN(cfun,
|
|||||||
}
|
}
|
||||||
const uint8_t *source = NULL;
|
const uint8_t *source = NULL;
|
||||||
if (argc >= 3) {
|
if (argc >= 3) {
|
||||||
source = janet_checktype(argv[2], JANET_STRING) ?
|
Janet x = argv[2];
|
||||||
janet_unwrap_string(argv[2]) :
|
if (janet_checktype(x, JANET_STRING)) {
|
||||||
janet_unwrap_keyword(argv[2]);
|
source = janet_unwrap_string(x);
|
||||||
|
} else if (janet_checktype(x, JANET_KEYWORD)) {
|
||||||
|
source = janet_unwrap_keyword(x);
|
||||||
|
} else {
|
||||||
|
janet_panic_type(x, 2, JANET_TFLAG_STRING | JANET_TFLAG_KEYWORD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
JanetArray *lints = (argc >= 4) ? janet_getarray(argv, 3) : NULL;
|
JanetArray *lints = (argc >= 4) ? janet_getarray(argv, 3) : NULL;
|
||||||
JanetCompileResult res = janet_compile_lint(argv[0], env, source, lints);
|
JanetCompileResult res = janet_compile_lint(argv[0], env, source, lints);
|
||||||
|
Loading…
Reference in New Issue
Block a user