Skip to content

fix string predicate method transpilation#40

Merged
medvednikov merged 1 commit intovlang:masterfrom
ylluminate:fix-isX-methods
Feb 20, 2026
Merged

fix string predicate method transpilation#40
medvednikov merged 1 commit intovlang:masterfrom
ylluminate:fix-isX-methods

Conversation

@ylluminate
Copy link
Contributor

@ylluminate ylluminate commented Feb 20, 2026

Fixes 7 Python string predicate methods that were either broken or missing.

Changes

  • isdigit/isalpha in transpiler.v: fix incorrect mappings to nonexistent is_digit()/is_alpha() string methods. V's character classification lives on u8, not string; the correct pattern is .bytes().all(fn (c u8) bool { return c.is_digit() })
  • isalnum/isspace: add missing methods using same bytes().all() pattern with is_alnum()/is_space()
  • islower/isupper/istitle: add missing methods mapping directly to V string methods is_lower()/is_upper()/is_title()
  • 1 new test case covering all 7 predicates plus 3 false-case inputs

Verification

Python V output Runtime match
"12345".isdigit() = True .bytes().all(...) with c.is_digit() true
"hello".isalpha() = True .bytes().all(...) with c.is_letter() true
"hello123".isalnum() = True .bytes().all(...) with c.is_alnum() true
" ".isspace() = True .bytes().all(...) with c.is_space() true
"hello".islower() = True .is_lower() true
"HELLO".isupper() = True .is_upper() true
"Hello World".istitle() = True .is_title() true
"hello123".isdigit() = False same pattern false
"hello123".isalpha() = False same pattern false
"hello".isupper() = False .is_upper() false

All 109 tests pass, 0 fail, 0 skip. V 0.5.0 a9423b5, macOS.

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.
@medvednikov medvednikov merged commit 5c86f2b into vlang:master Feb 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants