Skip to content

Conversation

Paul-Andre
Copy link
Contributor

@Paul-Andre Paul-Andre commented Jul 28, 2025

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 on check_expr_with_type_hint and could replace it, and calls to check_expr_or_type in certain places, in a future refactoring.

#5506

Comment on lines 8226 to 8265
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;
}
Copy link
Member

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

o->mode = Addressing_Invalid;
break;
}
case Addressing_ProcGroup : {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space before :

"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");
Copy link
Member

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");

gbString expr_str = expr_to_string(o->expr);

error(o->expr,
"Cannot use overloaded procedure '%s' as a runtime value",
Copy link
Member

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.

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.

Assertion Failure: type != t_invalid in llvm_backend_general.cpp(1643)

2 participants