-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: add type checker for unsigned integers #336
base: development
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,19 @@ | |
::MSU.requireTypeArray("integer", vargv); | ||
} | ||
|
||
::MSU.requireUnsigned <- function( ... ) | ||
{ | ||
::MSU.requireTypeArray("integer", vargv); | ||
foreach (value in vargv) | ||
{ | ||
if (value < 0) | ||
{ | ||
::logError(value + " must have the type: unsigned"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd argue unsigned isn't actually a type and therefore the error should be something more like.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that same vein what about the function name? Should it be something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah maybe that's better too |
||
throw ::MSU.Exception.InvalidType(value); | ||
} | ||
} | ||
} | ||
|
||
::MSU.requireArray <- function( ... ) | ||
{ | ||
::MSU.requireTypeArray("array", vargv); | ||
|
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 will say this use of the existing require check only seemed good back then.
But in reality this means that failing an unsigned integer check will print a "failed an integer check" message half the time. And that is not fully correct.
Ideally we would copy&paste the integer check logic in this check but swap out the printed exception