fix string predicate method transpilation#40
Merged
medvednikov merged 1 commit intovlang:masterfrom Feb 20, 2026
Merged
Conversation
Fix isdigit/isalpha which mapped to nonexistent string methods
(is_digit/is_alpha). V's character classification lives on u8,
not string; use .bytes().all(fn (c u8) bool { return c.is_X() }).
Add 5 missing predicate methods: isalnum, isspace, islower, isupper,
istitle. The first two use the bytes().all() pattern; the last three
map directly to V string methods.
109 tests pass, 0 fail, 0 skip.
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.
Fixes 7 Python string predicate methods that were either broken or missing.
Changes
isdigit/isalphaintranspiler.v: fix incorrect mappings to nonexistentis_digit()/is_alpha()string methods. V's character classification lives onu8, notstring; the correct pattern is.bytes().all(fn (c u8) bool { return c.is_digit() })isalnum/isspace: add missing methods using samebytes().all()pattern withis_alnum()/is_space()islower/isupper/istitle: add missing methods mapping directly to V string methodsis_lower()/is_upper()/is_title()Verification
"12345".isdigit()=True.bytes().all(...)withc.is_digit()true"hello".isalpha()=True.bytes().all(...)withc.is_letter()true"hello123".isalnum()=True.bytes().all(...)withc.is_alnum()true" ".isspace()=True.bytes().all(...)withc.is_space()true"hello".islower()=True.is_lower()true"HELLO".isupper()=True.is_upper()true"Hello World".istitle()=True.is_title()true"hello123".isdigit()=Falsefalse"hello123".isalpha()=Falsefalse"hello".isupper()=False.is_upper()falseAll 109 tests pass, 0 fail, 0 skip. V 0.5.0 a9423b5, macOS.