Commit 493e2978
493e29785175Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(parse): warn when require / require_relative cannot be resolved
Before this commit, require "foobar" was silently replaced with a
comment when foobar.rb wasn't found under <exe_dir>/lib/. The
compiled binary then ran as if the require had never been written.
For users porting CRuby code, that hid real load failures — the
program looked like it ran fine under spinel, but any call into
the missing library compiled to 0 further down, often producing
output that happened to look plausible.
The placeholder-comment substitution is kept (the program still
links / runs, matching the existing "best-effort" stance), but
both the require and require_relative paths now emit a one-line
warning to stderr naming the unresolved library and the directory
that was searched. Resolved-and-inlined requires stay silent.
Closes #596
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 493e29785175
- Parent
- 87a2ce25d6b7
spinel_parse.cmodifiedView file
sp_mark_path_included(canonical); content = read_file(full_path); if (!content) { fprintf(stderr, "warning: require_relative \"%s\" from %s could not be resolved (no such file: %s); the call is ignored\n", rel_path, source_path, full_path); content = strdup("# require_relative not found"); } else { /* Recursively resolve */ free(canonical); content = read_file(lib_path); if (!content) { fprintf(stderr, "warning: require \"%s\" could not be resolved (no %s.rb in %s); the call is ignored\n", lib_name, lib_name, lib_dir); content = strdup("# require not resolved"); } else { char *resolved = resolve_requires(content, lib_path);