# Plunit and optimise

**URL:** <https://swi-prolog.discourse.group/t/plunit-and-optimise/9848>\
**Category:** General\
**Tags:** bug\
**Created:** [October 2, 2026, 9:07pm UTC](https://swi-prolog.discourse.group/t/plunit-and-optimise/9848 "2026-10-02T21:07:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike.elston](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mike.elston/32/3691_2.png) [@mike.elston](https://swi-prolog.discourse.group/u/mike.elston)\
**Post date:** [October 2, 2026, 9:07pm UTC](https://swi-prolog.discourse.group/t/plunit-and-optimise/9848/1 "2026-10-02T21:07:58Z")

</div>

With this program:

```prolog
:- set_prolog_flag(optimise, true).

:- begin_tests(foo).

test(1) :-
   true.

:- end_tests(foo).

```

compiling the buffer works fine (Ctrl-c Ctrl-b) but make/0 (Ctrl-c Ctrl-m) gives an error:

```prolog
% /home/mike/odds_and_sods/test compiled 0.00 sec, 0 clauses
| ERROR: plunit:current_test/5: Unknown procedure: plunit_foo:'unit test'/4
ERROR: Unknown procedure: plunit_foo:'unit test'/4
ERROR: In:
ERROR: [15] throw(error(existence_error(procedure,...),context(...,_2108)))
ERROR: [13] read_term_with_history(_2132,[show(h),...|...]) at /home/mike/lib/swipl/boot/history.pl:55
ERROR: [11] call_cleanup('$toplevel':read_query('~! ?- ',_2188,_2190),'$toplevel':end_input_style) at /home/mike/lib/swipl/boot/init.pl:685
ERROR: [10] catch('$toplevel':call_cleanup(...,end_input_style),error(io_error(_2246,_2248),_2242),'$toplevel':fail) at /home/mike/lib/swipl/boot/init.pl:565

```

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [October 3, 2026, 7:54am UTC](https://swi-prolog.discourse.group/t/plunit-and-optimise/9848/2 "2026-10-03T07:54:43Z")

</div>

> [@mike.elston](#):
>
> ```prolog
> | ERROR: plunit:current_test/5: Unknown procedure: plunit_foo:'unit test'/4
> ERROR: Unknown procedure: plunit_foo:'unit test'/4
> 
> ```

Fixed as well by AI. I really love it for bug reports you copy/paste the URLs, wait a little and all is diagnosed and in well over 90% of the cases properly fixed 🙂 Only occasionally I have to correct that the suggested patch works, but is a step in the wrong direction and the bug should be fixed otherwise.
