Missunderstanding module functionality with operators?

I am having some problem to use operators that define set-theoretical functions in some .pl-file with use_module.

To illustrate that we can take the following test.pl-file:

:- module(test, [
    (:=)/2, op(699, xfx, :=),
    op(598, xfy, ∪),
    op(597, xfy, ∩)

union_((A ∪ B), C, D) :- union_(A, B, X), union_(X, C, D).
union_(A, (B ∪ C), D) :- union_((A ∪ B), C, D).
union_(A, B, C) :- is_list(A), is_list(B), union(A, B, C).

intersection_((A ∪ B), C, D) :- intersection_(A, B, X), intersection_(X, C, D).
intersection_(A, (B ∪ C), D) :- intersection_((A ∪ B), C, D).
intersection_(A, B, C) :- intersection(A, B, C).

C := (A ∪ B) :- union_(A, B, C).
C := (A ∩ B) :- intersection_(A, B, C).

If I now define another file test2.pl with the following code:

:- module(test2,[test2/1]).


test2(A) :- A := [1,2] ∪ [3,4].

it is not possible anymore to call something like that after swipl test2.pl:

?- C := ([1,2] ∪ [3,4]).
ERROR: Syntax error: Operator expected
ERROR: C := ([1,2]
ERROR: ** here **
ERROR: ∪ [3,4]) .

If I uncomment the line :- module(test2,[test2/1]). the call gives the desired result:

?- C := ([1,2] ∪ [3,4]).
C = [1, 2, 3, 4].

What is my error of understanding here? How can I give the in test2 some sense and use :- module(test2,[test2/1]). also?

Thanks for some quick reply!

Operators are imported and exported the same way as predicates. The test2 module only exposes test2/1. :=/2 and the two operators are only imported into test2. So, to make these operators available from the user module you should also import test into user or you should also export the operators from test2.

If you want to make stuff from multiple modules available for interactive use you’ll generally need a non-module file that imports the modules you want to have visible.