Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding type conversion for numeric

  • Loading branch information...
commit 65a21d1bbc6020d1ddd4969a697d93fa48a5e09c 1 parent f8537e7
@hongsup hongsup authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/frontend/gm_new_typecheck_step3.cc
View
12 src/frontend/gm_new_typecheck_step3.cc
@@ -362,12 +362,15 @@ bool gm_typechecker_stage_3::check_uop(ast_expr* e)
{
// should be alredy dest_type;
int dest_type = e->get_type_summary();
- if (!gm_is_prim_type(dest_type)) { // destination type
+ if (!gm_is_prim_type(dest_type)) // destination type
+ {
gm_type_error(GM_ERROR_TYPE_CONVERSION, l,c);
return false;
}
- if (!gm_is_prim_type(exp_type)) { // source type
+ if (!gm_is_prim_type(exp_type) &&
+ !gm_is_nodeedge_type(exp_type))
+ { // source type
gm_type_error(GM_ERROR_TYPE_CONVERSION, l,c);
return false;
}
@@ -375,7 +378,10 @@ bool gm_typechecker_stage_3::check_uop(ast_expr* e)
//
bool possible =
(gm_is_numeric_type(dest_type) && gm_is_numeric_type(exp_type)) ||
- (gm_is_boolean_type(dest_type) && gm_is_boolean_type(exp_type));
+ (gm_is_boolean_type(dest_type) && gm_is_boolean_type(exp_type) ||
+ (gm_is_numeric_type(dest_type) && gm_is_nodeedge_type(exp_type)) ||
+ false
+ );
if (!possible) {
gm_type_error(GM_ERROR_TYPE_CONVERSION_BOOL_NUM, l,c,"");
Please sign in to comment.
Something went wrong with that request. Please try again.