analysis: fix namespace parsing after Yojson migration#8454
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8454 +/- ##
==========================================
+ Coverage 60.63% 60.68% +0.04%
==========================================
Files 373 373
Lines 54057 54095 +38
==========================================
+ Hits 32778 32826 +48
+ Misses 21279 21269 -10
🚀 New features to boost your workflow:
|
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-8454 |
Member
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
cknitt
approved these changes
May 31, 2026
Contributor
|
Thank you to fix it @fhammerschmidt |
aspeddro
added a commit
to aspeddro/rescript-compiler
that referenced
this pull request
May 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@aspeddro
Problem
The Yojson migration changed analysis config parsing in a subtle way. The code
used
Yojson.Safe.Util.to_string_optionandto_bool_optionas if they werenon-throwing type probes, but Yojson's
_optionhelpers only returnNonefornull; they still raiseType_errorfor other mismatched JSON types.That broke valid namespace configs such as:
{ "namespace": "my-namespace" }because analysis first tried to decode
namespaceas a string, then also triedto decode it as a bool. The second probe raised instead of returning
None.The opposite shape,
{ "namespace": true }, had the same problem in reverse.Fix
Parse
namespaceonce into a closed OCaml variant:Then derive the existing string option from that typed representation. This
makes the bool/string/absent cases exhaustive and prevents later code from
probing the same raw JSON value as multiple incompatible types.
The patch also adds shared non-throwing Yojson helpers for config-style reads
and replaces the remaining unsafe Yojson option extractors in analysis and
reanalyze's
.sourcedirs.jsonscan-plan parsing.Coverage
Added OUnit coverage for namespace config parsing:
namespacenamespace: falsenamespace: true