Repository navigation
[json_syntax_generator] Pub format semver regexp fix - #3293
Conversation
Also add `-` to the allowed characters in pre-release and build identifiers. The RegExp over-matches (accepts some strings that are not valid SemVer versions), but now shouldn't reject any valid SemVer version strings.
PR HealthBreaking changes ✔️
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with |
Yes, that's an improvement! 🙏 No, we want no false negatives because we're reading random pubspecs and locks. (False positives is fine, the syntax classes cannot catch semantic errors, so there's always a second layer of validation. But things that are syntax errors are nicer if they are syntax errors. It means that semantic error checking doesn't need to have fallbacks for syntactic errors. But we don't have a semantic layer around the syntactic layer in this package. Unlike some of the other syntax definitions in this repo.) |
| const _validBuildParts = [ | ||
| ..._validPreReleaseParts, | ||
| // Also allows a leading zero, `0<digits>`. | ||
| '007', |
Fixes dart-lang/sdk#63110
The RegExp used to validate the package version in
pubspec.yamlallows a build-identifier (+....),the one for
pubspec.lockdoes not.This adds a
(?:\+...)?part to thepubspec.lockformat. Also adds-to the valid characters in pre-release and build identifier.(@dcharkes What is the goal of these version RegExps?
This fix should make them accept all valid SemVer versions, as well as some invalid versions. That's still an improvement on having both false positives and negatives - aka, an "extended subset".
If the goal is to have no false negatives, this PR should do that (I think!). That's a good goal, it means we won't complain on valid user-written versions.
If the goal is to have no false positives, I can build a RegExp for that. It'll be bigger, but it's possible.
If we want to allow false positives ... why do we allow some false positives, but not all? There a RegExp here, instead of just a
Stringtype, like there is forenvironment: sdk: "any string here". If we pass the version string to a SemVer parser later, then we'll catch the false positives there.)