diff --git a/src/language.yacc b/src/language.yacc index c48366159a603db744d0f235cd83230f7ae2c934..71a9f1586c40caeb790f5e1cf4018790014a5c11 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -1026,14 +1026,12 @@ def: modifiers optional_attributes type_or_error optional_constant optional_star /* fprintf(stderr, "Creating soft cast node for local #%d\n", e);*/ - local_node = mklocalnode(e, 0); + local_node = mkcastnode(mixed_type_string, mklocalnode(e, 0)); - /* The following is needed to go around the optimization in - * mksoftcastnode(). + /* NOTE: The cast to mixed above is needed to avoid generating + * compilation errors, as well as avoiding optimizations + * in mksoftcastnode(). */ - free_type(local_node->type); - copy_pike_type(local_node->type, mixed_type_string); - check_args = mknode(F_COMMA_EXPR, check_args, mksoftcastnode(Pike_compiler->compiler_frame->variable[e].type, @@ -2927,12 +2925,12 @@ class: TOK_CLASS line_number_info optional_identifier mixed_type_string)) { /* fprintf(stderr, "Creating soft cast node for local #%d\n", e);*/ - /* The following is needed to go around the optimization in - * mksoftcastnode(). - */ - free_type(local_node->type); - copy_pike_type(local_node->type, mixed_type_string); + local_node = mkcastnode(mixed_type_string, local_node); + /* NOTE: The cast to mixed above is needed to avoid generating + * compilation errors, as well as avoiding optimizations + * in mksoftcastnode(). + */ local_node = mksoftcastnode(Pike_compiler->compiler_frame-> variable[e].type, local_node); } diff --git a/src/las.c b/src/las.c index 7b4e1212c3dbb1234a532312ded6a46d3889f779..6e01e9ef214f020f7bffd2909022dbd770de97b0 100644 --- a/src/las.c +++ b/src/las.c @@ -387,9 +387,11 @@ static int check_node_type(node *n, struct pike_type *t, const char *msg) if (runtime_options & RUNTIME_CHECK_TYPES) { node *p = n->parent; if (CAR(p) == n) { - (_CAR(p) = mksoftcastnode(t, n))->parent = p; + (_CAR(p) = mksoftcastnode(t, mkcastnode(mixed_type_string, n))) + ->parent = p; } else if (CDR(p) == n) { - (_CDR(p) = mksoftcastnode(t, n))->parent = p; + (_CDR(p) = mksoftcastnode(t, mkcastnode(mixed_type_string, n))) + ->parent = p; } else { yywarning("Failed to find place to insert soft cast."); } @@ -3416,7 +3418,8 @@ void fix_type_field(node *n) free_string(t1); } if (runtime_options & RUNTIME_CHECK_TYPES) { - _CAR(n) = mksoftcastnode(CDR(n)->type, CAR(n)); + _CAR(n) = mksoftcastnode(CDR(n)->type, + mkcastnode(mixed_type_string, CAR(n))); } } }