V2 IsAlpha throwing TypeError Topic is solved

Report problems with documented functionality
fatodubs
Posts: 29
Joined: 20 Sep 2017, 18:53

V2 IsAlpha throwing TypeError

Post by fatodubs » 26 Jan 2023, 12:46

IsAlpha (and related IsXXX functions) throws a TypeError if the input isn't a string, but I feel like that's one of the primary uses of those functions. I understand I can use Try to get around it, but it feels like that's what those functions should be doing.

I'm very excited about the distinction between variable types, but they can still switch back and forth relatively easily. If I'm taking the time to check the current state of the variable, just returning 0 rather than throwing an error seems more appropriate.

just me
Posts: 9406
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: V2 IsAlpha throwing TypeError

Post by just me » 27 Jan 2023, 05:50

String
Check that a string matches a specific pattern. Value must be a string, otherwise a TypeError is thrown.

Code: Select all

If Var is String && IsAlpha(Var)
or

Code: Select all

If Type(Var) = "String" && ...

fatodubs
Posts: 29
Joined: 20 Sep 2017, 18:53

Re: V2 IsAlpha throwing TypeError

Post by fatodubs » 06 Feb 2023, 16:05

I get that there are workarounds - I mentioned using Try in my original post, which is probably what I would use rather than converting it to check it - but I feel like the function intended to check if a variable matches some criteria should return 0 if it does not rather than an TypeError.

lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: V2 IsAlpha throwing TypeError  Topic is solved

Post by lexikos » 15 Feb 2023, 02:06

The function is clearly intended to check whether a string matches specific criteria, not to check a "variable" or value of undetermined type. Other functions of this category could give surprising results if permitted to accept a number, therefore all functions of this category are designed to explicitly require a string, for code/documentation size and consistency.

Post Reply

Return to “Bug Reports”