-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"<unknown>" and "<command>" are not origins #1346
Conversation
The 'vcpkg install' blobs at the end aren't helpful. ```console PS D:\vcpkg-tool\out\build\Win-x64-Debug-WithArtifacts> .\vcpkg.exe install this-is-super-not-a-port#port error: expected eof on expression: this-is-super-not-a-port#port ^ vcpkg install <port name> <port name>... vcpkg install zlib zlib:x64-windows curl boost ```
# Conflicts: # azure-pipelines/end-to-end-tests-dir/cli.ps1 # include/vcpkg/input.h # src/vcpkg/commands.build-external.cpp # src/vcpkg/commands.build.cpp # src/vcpkg/commands.check-support.cpp # src/vcpkg/commands.depend-info.cpp # src/vcpkg/commands.export.cpp # src/vcpkg/commands.install.cpp # src/vcpkg/commands.remove.cpp # src/vcpkg/commands.set-installed.cpp # src/vcpkg/commands.upgrade.cpp # src/vcpkg/input.cpp
ExpectedL<ParsedQualifiedSpecifier> parse_qualified_specifier(StringView input); | ||
Optional<ParsedQualifiedSpecifier> parse_qualified_specifier(ParserBase& parser); | ||
} | ||
ExpectedL<ParsedQualifiedSpecifier> parse_qualified_specifier(StringView input, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because all of the "finalizer" functions on ParsedQualifiedSpecifier
have been changed to strict contracts, I don't think this intermediate is providing any value to consumers.
It seems like it would be better to just remove them and supply type-safe free functions:
ExpectedL<FullPackageSpec> parse_full_spec(StringView input, AllowFeatures allow_features, ParseExplicitTriplet parse_explicit_triplet, ImplicitDefault id, Triplet default_triplet);
ExpectedL<PackageSpec> parse_full_spec(StringView input, ParseExplicitTriplet parse_explicit_triplet, Triplet default_triplet);
(This could be done in a follow-up PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree and tried to do this, but there are 2 problems:
- The existing separation is still used to allow the
StringView input
andParserBase& input
overloads. I tried to change everything to StringView in this work but sadly the ParserBase overload has good reasons to be there. - There are callers who explicitly want the non-'finalized' version, such as:
vcpkg-tool/src/vcpkg/binaryparagraph.cpp
Lines 46 to 54 in 56b4a5b
parse_qualified_specifier_list(parser.optional_field(ParagraphIdDepends)).value_or_exit(VCPKG_LINE_INFO), | |
[my_triplet](const ParsedQualifiedSpecifier& dep) { | |
// for compatibility with previous vcpkg versions, we discard all irrelevant information | |
return PackageSpec{ | |
dep.name, | |
dep.triplet.map([](auto&& s) { return Triplet::from_canonical_name(std::string(s)); }) | |
.value_or(my_triplet), | |
}; | |
}); |
@@ -58,6 +58,7 @@ namespace vcpkg::Json | |||
const std::vector<LocalizedString>& warnings() const { return m_warnings; } | |||
|
|||
std::string path() const noexcept; | |||
StringView origin() const noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is origin
for ParserBase
an Optional<StringView>
but for JsonReader
a StringView
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParserBase is reasonably used for things that don't have origins, like content from environment variables or command lines. At least at present, JSON only comes from honest to goodness files which always have origins, so making the parameter nullable is unnecessary.
src/vcpkg/binaryparagraph.cpp
Outdated
.value_or_exit(VCPKG_LINE_INFO); | ||
TextRowCol defaultFeaturesRowCol; | ||
this->default_features = | ||
parse_default_features_list(parser.optional_field(Fields::DEFAULT_FEATURES, defaultFeaturesRowCol), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another case of argument evaluation order UB. I think the .optional_field
type signature is prone to this problem; would it make sense to rename the function and return a pair instead?
src/vcpkg/commands.help.cpp
Outdated
@@ -23,6 +23,13 @@ namespace | |||
|
|||
LocalizedString help_topics(); | |||
|
|||
LocalizedString help_topic_valid_triplet(const TripletDatabase& database) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function used to print the help to the screen, but now returns a result. This is very likely to make all consumers silently incorrect -- I see two cases in this file. This should either be changed back to the previous behavior or be attributed with [[nodiscard]]
to help catch the cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I meant to revert interface changes to this function, will do that.
|
||
void check_triplet(StringView name, const TripletDatabase& database); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function is changing from a side effect to a return value, I think it should at least gain a [[nodiscard]]
or (preferably) change its name. All callers must change anyway to use the returned value, so it seems very low cost to also change the identifier.
# Conflicts: # include/vcpkg/documentation.h # src/vcpkg/binaryparagraph.cpp # src/vcpkg/packagespec.cpp # src/vcpkg/paragraphs.cpp
{ | ||
if (check_origin->empty()) | ||
{ | ||
Checks::unreachable(VCPKG_LINE_INFO, "origin should not be empty"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this change I see this error:
$ /vcpkg format-manifest scripts/test_ports/vcpkg-ci-skia/vcpkg.json
/home/<me>/vcpkg-tool/src/vcpkg/base/parse.cpp(106): origin should not be empty
Aborted (core dumped)
No description provided.