mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
error when using a type not usable as boolean in a condition, ie an if statement
This commit is contained in:
parent
7fb3b97e73
commit
9afe41471b
1 changed files with 6 additions and 0 deletions
6
parser.c
6
parser.c
|
@ -2205,6 +2205,12 @@ static ast_expression* process_condition(parser_t *parser, ast_expression *cond,
|
|||
ast_unary *unary;
|
||||
ast_expression *prev;
|
||||
|
||||
if (cond->expression.vtype == TYPE_VOID || cond->expression.vtype >= TYPE_VARIANT) {
|
||||
char ty[1024];
|
||||
ast_type_to_string(cond, ty, sizeof(ty));
|
||||
compile_error(ast_ctx(cond), "invalid type for if() condition: %s", ty);
|
||||
}
|
||||
|
||||
if (OPTS_FLAG(FALSE_EMPTY_STRINGS) && cond->expression.vtype == TYPE_STRING)
|
||||
{
|
||||
prev = cond;
|
||||
|
|
Loading…
Reference in a new issue