Repository navigation
Make the guide's guard example print what it shows - #140
Open
quinnj-bot[bot] wants to merge 1 commit into
Open
quinnj-bot[bot] wants to merge 1 commit into
quinnj-bot[bot] wants to merge 1 commit into
Conversation
nothing in a pattern is an identifier that binds a variable, so the
example's ("-h" || "--help", nothing) case matched any value and
("-l", lang) matched ("-l", nothing). Use ::Nothing and lang::String,
update the shown tuple printing, and note under Notes/Gotchas how to
match named constants.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #140 +/- ##
=======================================
Coverage 99.38% 99.38%
=======================================
Files 12 12
Lines 1132 1132
=======================================
Hits 1125 1125
Misses 7 7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Why
The guide's guard example shows output that its code does not produce, and it teaches a pattern that silently matches everything. In the example,
nothingis an identifier, so("-h" || "--help", nothing)binds a new variable namednothingand matches any second value.("-l", lang)matches("-l", nothing), soparse_arg("-l")printsLanguage set to nothing, not theUnknown argument: ("-l",nothing)the guide shows.What changed
parse_argexample uselang::Stringand::Nothing, so every shown output is what the code prints. The test suite's copy of this example already guardslangthe same way.("-l", nothing)).nothing,missingandNaNare identifiers in a pattern, and how to match the constant itself (::Nothing,::Missing,$(NaN)).Verification
I extracted both
parse_argversions fromdocs/src/index.mdand ran them on Julia 1.12.6. With this branch, every call prints the line the guide shows, and both versions agree:With
main's version,parse_arg("-l")printsLanguage set to nothingandparse_arg("-h", 5)printsHelp!.libopenlibm.so: cannot enable executable stack). PR Fix @match on 32-bit Julia (hash seeds typed as UInt64) #134 shows the same failure; this PR does not touch CI.🤖 Generated with Claude Code