plugin: type-check errors always report "parameter number 1"
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 70/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend, build-system
Direzione di ricerca
Start with the EXTENSION_FUNCTION_CHECK_ITERATOR macro in source/plugin/include/plugin/plugin_interface.hpp (around line 76), where the index is stringified instead of printed. Then check the preprocessed load() in the cli_core_plugin source and the metacall_cli_core_plugin_test CMakeLists.txt, whose early return depends on the order of add_subdirectory calls in source/CMakeLists.txt. Done when the message names the wrong parameter's index, a test checks the second-parameter message, and the test actually runs under ctest.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🐛 Bug Report
When a plugin function gets an argument of the wrong type, the error message always says "The parameter number 1", whichever parameter was wrong.
Expected Behavior
The message names the parameter that has the wrong type, for example "The parameter number 2" when the second argument is wrong.
Current Behavior
Every type error says "The parameter number 1":
args[0] = 5 (Int) -> Failed to load a script. The parameter number 1 requires a value of type String, received: Int
args[1] = "x" (String) -> Failed to load a script. The parameter number 1 requires a value of type Array, received: String
EXTENSION_FUNCTION_CHECK_ITERATOR builds the message with this (plugin_interface.hpp#L76):
PREPROCESSOR_STRINGIFY(PREPROCESSOR_ARGS_COUNT(iterator))
iterator is the index that PREPROCESSOR_FOR passes in (0, 1, ...). PREPROCESSOR_ARGS_COUNT(iterator) counts how many macro arguments that is, which is always 1, instead of using its value. The preprocessed load() in cli_core_plugin.cpp shows it: both checks have the string "1".
Possible Solution
Print the index instead of counting it, starting from 1 like extension_function_check_array in cli_core_plugin.cpp already does ("#" << (i + 1)):
ss << error ". The parameter number " << ((iterator) + 1) << " requires a value of type " << ...
And add a test in metacall_cli_core_plugin_test that checks the message for the second parameter. I'd also fix the typo "argumens" in the argument count message of the same file, if that's OK.
Related problem I found while adding the test: metacall_cli_core_plugin_test is never built. Its CMakeLists.txt returns early with NOT TARGET cli_core_plugin, but source/CMakeLists.txt adds tests before cli, so that target doesn't exist yet when the check runs. Three more tests have the same check and are skipped too: metacall_cli_core_plugin_await_test, metacall_plugin_extension_destroy_order_test and metacall_plugin_extension_invalid_path_test (since 3a631c67 and 24db326a in 2024). None of them appear in the Linux CI logs (for example, the GCC debug job of the last develop run, 212 tests).
Moving add_subdirectory(cli) before add_subdirectory(tests) fixes it. Locally the skipped tests pass after that (the await test needs the Node port, which I didn't build), and the full ctest passes 111/111. Without it, the new test wouldn't run in CI. Should I include it in the same PR as a separate commit, or open a separate issue for it?
Steps to Reproduce
- Build with the CLI (
OPTION_BUILD_LOADERS_NODE=ON, which buildscli_core_plugin). - Load the plugin and call
loadwith a String as the second argument (it expects an Array). I used a String because MetaCall converts numbers to an Array before the call, so they never reach this check.
void *handle = NULL;
metacall_load_from_configuration(CLI_CORE_PLUGIN_PATH, &handle, allocator);
void *args[2] = { metacall_value_create_string("node", 4), metacall_value_create_string("x", 1) };
void *ret = metacallhv_s(handle, "load", args, 2);
struct metacall_exception_type ex;
metacall_error_from_value(ret, &ex);
printf("%s\n", ex.message); /* "... The parameter number 1 requires a value of type Array, received: String" */
- The message says parameter 1, but the wrong one is the second.
Context (Environment)
Found while working on #560. develop at 11e2b835, Ubuntu 24.04, GCC 13.3. It's in the macro, so every plugin that uses EXTENSION_FUNCTION_CHECK is affected (CLI core and sandbox plugins, sandbox plugin).
I already have the fix, the test and the CMake change working locally (the full ctest passes with GCC and Clang), and I'd like to open the PR for this myself. It touches the same header as #954, but different lines, and it applies cleanly on top of it. Can I go ahead?
- Lingua principale
- C
- Stelle
- 1.8k
- Fork
- 266
- Merge medio
- 2g 16h
- PR unite (30g)
- 14
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di metacall/core
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
metacall/core#964 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
pre-push hook empties VERSION when the clone has no tagsForse già presa @vedant21-oss l’ha presa 17 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
metacall/core#939 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
TOCTOU race condition vulnerability!Forse già presa @akshatchitransh l’ha presa 1 giorno fa. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
metacall/core#961 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Go Port Race Conditions on MacOSForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
metacall/core#942 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Stack buffer overflow in `metacall.c` — is the 16-argument limit intentional?Forse già presa @10vulture1005 l’ha presa 34 giorni fa. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 28/100
metacall/core#923 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di metacall/core
Issue simili
-
agent:WSL code-review linux pri:low refactoring tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
DOC BUG Missing
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SDL-Hercules-390/hyperion#911 ·
I maintainer di solito rispondono entro 1 giorno
-
build: man page directory doubledForse già presa @zeusgoose l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
esp-mosaico/esp-mosaico-bsp#40 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100