-
-
Notifications
You must be signed in to change notification settings - Fork 837
Fix issue 5506 and add check_expr_as_value #5511
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
base: master
Are you sure you want to change the base?
Conversation
b3dfbb4
to
c000ff5
Compare
src/check_expr.cpp
Outdated
case Addressing_Type: { | ||
ERROR_BLOCK(); | ||
gbString expr_str = expr_to_string(o->expr); | ||
|
||
error(o->expr, | ||
"Cannot use type '%s' as a runtime value", | ||
expr_str); | ||
|
||
error_line("\tUse typeid_of to convert it to a typeid that can be used at runtime\n"); | ||
|
||
gb_string_free(expr_str); | ||
o->mode = Addressing_Invalid; | ||
break; | ||
} | ||
case Addressing_Builtin: { | ||
ERROR_BLOCK(); | ||
gbString expr_str = expr_to_string(o->expr); | ||
|
||
error(o->expr, | ||
"Cannot use built-in procedure '%s' as a runtime value", | ||
expr_str); | ||
|
||
error_line("\tBuilt-in procedures are implemented by the compiler and might not be actually instantiated procedures\n"); | ||
|
||
gb_string_free(expr_str); | ||
o->mode = Addressing_Invalid; | ||
break; | ||
} | ||
case Addressing_ProcGroup : { | ||
ERROR_BLOCK(); | ||
gbString expr_str = expr_to_string(o->expr); | ||
|
||
error(o->expr, | ||
"Cannot use overloaded procedure '%s' as a runtime value", | ||
expr_str); | ||
|
||
gb_string_free(expr_str); | ||
o->mode = Addressing_Invalid; | ||
break; | ||
} |
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.
Please follow the style of the rest of the code base and don't indent cases
src/check_expr.cpp
Outdated
o->mode = Addressing_Invalid; | ||
break; | ||
} | ||
case Addressing_ProcGroup : { |
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.
Extra space before :
src/check_expr.cpp
Outdated
"Cannot use type '%s' as a runtime value", | ||
expr_str); | ||
|
||
error_line("\tUse typeid_of to convert it to a typeid that can be used at runtime\n"); |
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.
That phrasing is a bit confusing. Prefer:
error_line("\tuse 'typeid_of' to convert a type to a runtime 'typeid' value\n");
src/check_expr.cpp
Outdated
gbString expr_str = expr_to_string(o->expr); | ||
|
||
error(o->expr, | ||
"Cannot use overloaded procedure '%s' as a runtime value", |
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.
Well overloaded procedures can be used if the type can be inferred correctly.
c000ff5
to
a1027c3
Compare
The fix was basically making sure we additionally check that the operands of a ternary_if are not Builtin and not ProcGroup
The new function
check_expr_as_value
is based oncheck_expr_with_type_hint
and could replace it, and calls tocheck_expr_or_type
in certain places, in a future refactoring.#5506