diff --git a/src/core/chuck_scan.cpp b/src/core/chuck_scan.cpp index 5d2b02a64..158c80787 100644 --- a/src/core/chuck_scan.cpp +++ b/src/core/chuck_scan.cpp @@ -3082,16 +3082,21 @@ t_CKBOOL type_engine_scan2_func_def( Chuck_Env * env, a_Func_Def f ) // make a new type for the function type = env->context->new_Chuck_Type( env ); + // type id type->xid = te_function; - type->base_name = "[function]"; + // type size type->size = sizeof(void *); - + // function type name; this will be updated later in this function once we have more info (e.g., value_ref) + type->base_name = "[fun]"; // 1.5.4.3 (ge) add ref; was: type->parent_type = env->ckt_function; // part of #2024-func-call-update - CK_SAFE_REF_ASSIGN(type->parent_type,env->ckt_function); + CK_SAFE_REF_ASSIGN(type->parent_type, env->ckt_function); // 1.5.4.3 (ge) add ref; was: type->func_bridge = func; - // part of #2024-func-call-update + // part of #2024-func-call-update | TODO: break cycle? CK_SAFE_REF_ASSIGN(type->func_bridge, func); + // 1.5.4.3 (ge) add func to type reference + // part of #2024-func-call-update | TODO: break cycle? + CK_SAFE_REF_ASSIGN(func->type_ref, type); // make new value, with potential overloaded name value = env->context->new_Chuck_Value( type, func_name ); @@ -3409,10 +3414,13 @@ t_CKBOOL type_engine_scan2_func_def( Chuck_Env * env, a_Func_Def f ) assert( f->code == NULL || f->code->s_type == ae_stmt_code ); if( f->code && !type_engine_scan2_code_segment( env, &f->code->stmt_code, FALSE ) ) { - EM_error2( 0, "...in function '%s'", func->signature().c_str() ); // S_name(f->name) ); + EM_error2( 0, "...in function '%s'", func->signature(FALSE,FALSE).c_str() ); // S_name(f->name) ); goto error; } + // update the function-specific type's name | 1.5.4.3 (ge) added + type->base_name = "[fun]" + func->signature(FALSE,FALSE); + // pop the value stack env->curr->value.pop(); // clear the env's function definition diff --git a/src/core/chuck_type.cpp b/src/core/chuck_type.cpp index 617790cb0..39c7b735f 100644 --- a/src/core/chuck_type.cpp +++ b/src/core/chuck_type.cpp @@ -9316,7 +9316,9 @@ Chuck_Type * Chuck_Func::type() const string Chuck_Func::signature( t_CKBOOL incFuncDef, t_CKBOOL incRetType ) const { // check we have the necessary info - if( !value_ref || !def() || !def()->ret_type ) + // 1.5.4.3 (ge) added conditional check on ret_type + // to allow this function to be used pre-typecheck + if( !value_ref || !def() || (incRetType && !def()->ret_type) ) return "[function signature missing info]"; // check if a member func diff --git a/src/test/06-Errors/error-string-func-concat-1.txt b/src/test/06-Errors/error-string-func-concat-1.txt index 9faaf555a..27e2281c8 100644 --- a/src/test/06-Errors/error-string-func-concat-1.txt +++ b/src/test/06-Errors/error-string-func-concat-1.txt @@ -1,4 +1,4 @@ -error-string-func-concat-1.ck:17:9: error: cannot perform '+' on string and '[function]' +error-string-func-concat-1.ck:17:9: error: cannot perform '+' on string and '[fun]Foo.getFoo()' [17] <<< " " + f.getFoo >>>; ^ error-string-func-concat-1.ck:17:13: error: ...(hint: to call the function, add '()' and any arguments) diff --git a/src/test/06-Errors/error-string-func-concat-2.txt b/src/test/06-Errors/error-string-func-concat-2.txt index 608c30e2a..e58b6696d 100644 --- a/src/test/06-Errors/error-string-func-concat-2.txt +++ b/src/test/06-Errors/error-string-func-concat-2.txt @@ -1,4 +1,4 @@ -error-string-func-concat-2.ck:12:9: error: cannot perform '+' on '[function]' and string +error-string-func-concat-2.ck:12:9: error: cannot perform '+' on '[fun]Foo.bar()' and string [12] Foo.bar + " "; ^ error-string-func-concat-2.ck:12:5: error: ...(hint: to call the function, add '()' and any arguments) diff --git a/src/test/06-Errors/error-string-func-concat-3.txt b/src/test/06-Errors/error-string-func-concat-3.txt index 1e72f2f68..0d135403f 100644 --- a/src/test/06-Errors/error-string-func-concat-3.txt +++ b/src/test/06-Errors/error-string-func-concat-3.txt @@ -1,4 +1,4 @@ -error-string-func-concat-3.ck:9:5: error: cannot perform '+' on '[function]' and string +error-string-func-concat-3.ck:9:5: error: cannot perform '+' on '[fun]foo()' and string [9] foo + ""; ^ error-string-func-concat-3.ck:9:1: error: ...(hint: to call the function, add '()' and any arguments)