Subscribing with an incorrect wrapper does not cause compilation to fail.

Summary

The problem I’m encountering is this: I have a wrapper to subscribe to events that initially return an Agent. I’m using it to obtain additional information.

This is what it looks like (Note that I found this code a long time ago on the forum.) :

(Listenable : listenable(agent)).SubscribeAgent(OutputFunc : tuple(agent, t)->void, ExtraData : t where t:type) : cancelable =
    Wrapper := wrapper_agent(t){ExtraData := ExtraData, OutputFunc := OutputFunc}
    Listenable.Subscribe(Wrapper.InputFunc)
 
wrapper_agent(t : type) := class():
    ExtraData : t;
    OutputFunc : tuple(agent, t) -> void
    InputFunc(Agent : agent):void = OutputFunc(Agent, ExtraData)

Here is an example of its use:

Button.InteractedWithEvent.SubscribeAgent(Test, i)

The problem I am encountering is that if we use this wrapper which returns an ?agent, the compilation works correctly and we do not have any particular errors.

Timer.SuccessEvent.SubscribeAgent(Test, i)

If the function is triggered, the session will freeze and crash, without any error being reported in the creator portal.

I don’t know if this is a true error or not, but it seems to me that in the past, this displayed errors in VS Code.

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

Create a code with an agent wrapper for a device that returns an ?agent. The session should crash if this function is triggered.

Expected Result

Errors are displayed in VS Code because the expected function type is (agent, t) and not (?agent, t)

Observed Result

The uefn session is over.

Platform(s)

Windows 11