Skip to content

Commit

Permalink
Fix get_type_info()/closure_to_string() showing wrong program name
Browse files Browse the repository at this point in the history
get_type_info(cl, 3) should return the program/inherit containing the
target function, but instead returned the object's main program.
Similarly closure_to_string() did not print the inherit name for
inherited functions.
  • Loading branch information
amotzkau committed Sep 27, 2023
1 parent 528e3d9 commit 57f5067
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/closure.c
Original file line number Diff line number Diff line change
Expand Up @@ -5879,8 +5879,6 @@ closure_lookup_lfun_prog ( lfun_closure_t * l
if (*pProg != prog)
is_inherited = MY_TRUE;

/* Copy the other result values */
*pProg = prog;
*pIsInherited = is_inherited;
} /* closure_lookup_lfun_prog() */

Expand Down
5 changes: 5 additions & 0 deletions test/t-0000233/a2.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ closure get_a_var_cl4()
{
return lambda(0, ({symbol_variable("a_var")}));
}

closure get_a_calc_cl()
{
return #'calc;
}
5 changes: 5 additions & 0 deletions test/t-0000233/b.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ closure get_b_var_cl2()
{
return lambda(0, ({#'b_var}));
}

closure get_b_calc_cl()
{
return #'b_calc;
}
5 changes: 5 additions & 0 deletions test/t-0000233/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ closure get_c_var_cl2()
{
return lambda(0, ({#'c_var}));
}

closure get_c_calc_cl()
{
return #'c_calc;
}
16 changes: 16 additions & 0 deletions test/t-0000233/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ void run_test()
return funcall(d->get_a_var_cl()) == "a";
:)
}),
({ "Run " + testname + ": Check for program of closure in 'a'.", 0,
(:
return get_type_info(d.get_a_calc_cl(), 3) == "/a";
:)
}),
({ "Run " + testname + ": Check for program of closure in 'b'.", 0,
(:
return get_type_info(d.get_b_calc_cl(), 3) == "/b";
:)
}),
({ "Run " + testname + ": Check for program of closure in 'c'.", 0,
(:
closure cl = d->get_c_calc_cl();
return cl ? get_type_info(cl, 3) == "/c" : 1;
:)
}),
({ "Run " + testname + ": Check for virtual variable lambda closures in 'a'.", 0,
(:
return funcall(d->get_a_var_cl2()) == "a";
Expand Down

0 comments on commit 57f5067

Please sign in to comment.