Repository navigation
fix(checker): honest NSE name lists with a stub-overlap guard - #149
Conversation
…helpers Mechanical prefix of #130. Semantics are unchanged; the full crate suite passes untouched. - apply_narrowing loses its unused _has_else parameter and returns early for Narrowing::None, so a no-narrowing if skips the match-arm work while still returning owned scopes. - merge_branch_bindings takes the branch scopes by reference; the caller no longer clones both just to keep reading them. - infer_if_expr no longer clones the branch scopes it consumes last. - One is_comparison predicate replaces the six-operator list written out at six sites. - One concrete_json_mode mapping replaces the JsonMode-to-Mode table written out three times. - extract_builtin_type_narrowing shares its inherits target lookup and first-argument identifier extraction; apply_narrowing shares the narrow-away-from-null sequence repeated across four arms. - try_s3_binop_dispatch and try_s3_unary_dispatch share the class vector walk. - equality_list_leaf_type loses its dead op parameter; unused span and name parameters are underscore-named at the signature instead of silenced in the body; a mid-file use moves to the top of misc.rs.
… emitter Second half of #130. Semantics are unchanged; the full crate suite passes untouched. - enter_function_body unifies the two ~55-line function-body walks in walk_stmt. The Assign arm passes its binding name plus a flag for the S3 dispatch context, the only line that differed. - emit_condition_diagnostics replaces the RY001/RY003/RY002 block written three times across walk_stmt's If and While arms and infer_if_expr. A ConditionContext selects the message noun and carries the While arm's missing RY002 case unchanged: the rule table scopes RY002 to `if` conditions, and that arm has never had it. - trusted_defusers is cached on the Checker instead of being rebuilt from DEFUSING_CALLS plus the whole fn table on every function per fixpoint iteration. collect_fns clears it, matching the only pass that writes fn_table.fns. - infer_call builds one ArgumentMatch per call. eval_mode_for_arg and bound_argument_index_matched consume it, so the argument loop is no longer O(n^2) and the assertion path matches once instead of three times. argument_eval_mode stays for the schema-call site outside infer/. - infer_data_frame calls longest_arg_length instead of repeating its ladder. infer_rep resolves times and each through rep_count. - list_binding_origin is inlined into its single caller. - The structure(x, class=...) doc comment moves from infer_injected_call, which handles typeshed injection, to infer_structure_call, which it describes.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Important
The removals themselves check out — every deleted entry was verified against all 32 vendored package stubs, and the suite is green. But the anti-drift guard only sees one of the eval modes that create fallback overlap (mutation-proven below), and one kept member already violates the "no stub declares its evaluation mode" membership rule. Details inline.
Reviewed changes
- NSE fallback list pruned to stub-uncovered names —
is_nse_symbol_fnis now backed by theNSE_SYMBOL_FNSconst (26 entries); removedtidyselect(a package name),alist(base stub dots arequoted_expression), and the six rlang defusing helpers whose stubs declarecaptures_promise. Thealistlist-return special case ininfer_callwent with it, replaced by the stub's ownlistreturn. - Overlap guard test —
nse_symbol_fallback_does_not_overlap_stub_promise_captureenumerates the const against the stub promise-capture index, which required promotingpromise_capture_indextopub(crate). - RY092 dispatch alignment —
generic_argument_may_dispatchnow consultstypeshed.globals.s3_generics, the same list the dispatch path reads, plus a five-name fallback. Verified inert against every vendored stub today (none of those names has a typed param), so this is forward alignment, not a behavior change. - Behavior pins and CHANGELOG — new tests pin the stub-driven rlang/
alistpaths and the two observable changes (a literaltidyselect(...)call and unloaded unqualified defusing calls now report RY010). Fullcargo test -p ry-checkergreen locally; the### Fixedentry matches the section's sibling style.
ℹ️ Nitpicks
- The five-name fallback in
generic_argument_may_dispatchkeepsround,log,sqrt, andexphardcoded, but those four are already Math-group members ins3_group_generic(crates/ry-checker/src/higher_order.rs:673) — the dispatch path's other source. Deriving them froms3_group_generic(&function_name).is_some()(keeping onlymean, which is in neither source) would mirror dispatch exactly and drop the list to one name. Inert today either way, so purely optional.
openai-compatible/glm-5.3 | 𝕏
…on-walks # Conflicts: # CHANGELOG.md # crates/ry-checker/src/infer/binop.rs
The cache was built during fixpoint iteration 1 (nested function literals fire check_lazy_default_reachability in pass 2) and survived the quoting propagators, so the pass-3 RY098 walk could read a pre-propagation snapshot. Both propagators and signature seeding now clear it whenever they write quoting/defused flags. Regression test pins that a cached set matches the post-propagation table.
…nto fix/infer-name-list-honesty # Conflicts: # CHANGELOG.md
… NSE fallback The guard now scans every stub eval mode, not just captures_promise, so a member quoted or data-masked by any stub must leave the fallback list. all_vars leaves: dplyr declares expr: data_mask for it, and the fallback intercepted even dplyr::all_vars() before signature resolution. Pin the new paths: qualified and loaded calls data-mask their expression, an unloaded unqualified call evaluates its argument (RY010). generic_argument_may_dispatch derives the Math-group names from s3_group_generic, keeping only mean hardcoded.
|
Addressed all three findings in c6dc2b1 (on top of a merge from the moved base). Guard widened.
Dispatch fallback aligned.
|
There was a problem hiding this comment.
✅ No new issues found. Both findings from the prior review are fully addressed — I re-ran the mutation checks that exposed them, and the widened guard now catches both shapes.
Reviewed changes
- Overlap guard widened to every eval mode —
nse_symbol_fallback_does_not_overlap_stub_eval_modesnow scans base plus everyknown_packages()entry (all 32 vendored packages) for any non-NormalEvalModekeyed under a member name, with an empty, documenteddata_mask/tidy_selectexemption fixture;promise_capture_indexwent back to private. Mutation-verified: re-adding bothalistandall_varsfails the guard with["all_vars (DataMask)", "alist (QuotedExpression)"]— exactly the two blind spots the old guard missed. all_varsleft the fallback list — dplyr's stub declaresexpr: data_maskfor it, so qualified andlibrary(dplyr)calls now reach that metadata (no RY010, and RY040 still fires inside the mask), while unloaded unqualified calls report RY010. The const's doc comment and the CHANGELOG entry both state the dplyr rationale.- RY092 dispatch fallback collapsed to
mean—generic_argument_may_dispatchnow derivesround/log/sqrt/expfroms3_group_generic(the dispatch path's other source) and consultsglobals.s3_generics, matching dispatch exactly; the doc comment names both sources. Confirmedmeanis in neither, so the single hardcoded name is correct.
Verification this run: a fresh scan of all 32 vendored stubs shows zero eval-metadata overlap for the 25 remaining members; cargo test -p ry-checker --lib green (468 tests); cargo fmt --check and clippy -D warnings clean.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using openai-compatible/glm-5.3 | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline (a one-word CHANGELOG revert the merge silently carries).
Reviewed changes
Since the last review the PR was retargeted from refactor/infer-function-walks to main (its stack landed as #137/#145) and origin/main was merged in. The PR's own code is unchanged from the approved state; the delta is integration.
- Retargeted to
mainand mergedorigin/main— brings in #143–#148 (typeshedFunctionSigdeserialization, the CLI/LSP refactors, and thecollect.rswalker collapse). Verified the merge is lossless: the stack's content — the single function-entry path, the condition-diagnostics emitter, thetrusted_defuserscache with its pin test — now lives onmainvia #145, andorigin/main...HEADis exactly the six fix files. - PR delta vs
mainis byte-identical to the previously approved diff — a range-diff against the last-reviewed head (c6dc2b1) shows only stack hunks leaving the diff; no fix-commit hunk changed. - Re-validated against the merged tree —
cargo test -p ry-checker --libgreen (469 tests, including the widened overlap guard and all six pin tests), so #143's typeshed refactor and #148's walker collapse did not disturb the stub-eval paths this PR depends on. The only blemish found is the inline CHANGELOG nit.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openai-compatible/glm-5.3 | 𝕏
| - The test harness's async JSON-RPC decoder now applies the same 16 MiB | ||
| message cap as the blocking decoder, rejecting oversized headers instead | ||
| of buffering them without limit. | ||
| of buffering without limit. |
There was a problem hiding this comment.
The merge kept the branch's pre-#139 wording here, so the PR diff now silently reverts a one-word fix from main: #139 (8577b2d) authored "of buffering them without limit." for the async-decoder entry, and merging this PR as-is drops "them" again. Restoring main's wording makes this line leave the diff entirely.

Summary
is_nse_symbol_fnis the hardcoded half of the NSE knowledge. The typeshedevalmetadata is the other half. This PR deletes the entries the stubs already cover, keeps the ones they do not, and adds a guard so the two halves cannot overlap silently. It also wiresgeneric_argument_may_dispatchto the sames3_genericslist the dispatch path reads. Stacked on #145 (which stacks on #137); merges after both.Changes
is_nse_symbol_fn:tidyselectis a package name, not a function. A call spelledtidyselect(...)now evaluates its arguments.alistis covered by the base stub'squoted_expressiondots. The stub path also keeps the list return type.enexpr,ensym,enquo,enquos,ensyms, andquosare covered by rlang'scaptures_promisemetadata. Loaded or qualified calls resolve the stub. Unqualified calls withoutlibrary(rlang)now evaluate their arguments.quote,substitute,bquote, anddelayedAssignhave base stubs withoutevalfields.makeActiveBinding, the ggplot2 and data.table names, the remaining rlang names, andall_vars/peek_varshave no coverage. Blocked on r-typeshed.NSE_SYMBOL_FNSconst so tests can enumerate it.generic_argument_may_dispatchnow consultstypeshed.globals.s3_generics, the same list the S3 dispatch path reads. The stub list omitsround,mean,log,sqrt, andexp, so a five-name fallback stays and a comment says why.assertion_call_targetand the stub-assertion path ininfer_callnow carry cross-reference comments. Both sites encode the same knowledge. The fold-in is blocked on r-typeshed (Consolidate three independent NSE/defusing function encodings #41).### Fixedentry: RY010 now fires where bogus or redundant entries suppressed it.Verification
nse_symbol_fallback_does_not_overlap_stub_promise_capturefails when a member is stub-covered and lists the overlap. Verified by temporarily re-addingenquo.alistand the six rlang helpers. They pass before and after the removals.tidyselect(...)call and an unloaded unqualified defusing call now report RY010.cargo fmt -p ry-checkercargo clippy -p ry-checker --all-targets -- -D warningscargo test -p ry-checker— full suite green, corpus snapshots included.Implements the in-repo part of #41 and #49