False positive "is defined but never used" warning if event type in contract interface #491

Closed
opened 2023-11-19 15:04:43 +09:00 by davidyuk · 2 comments
davidyuk commented 2023-11-19 15:04:43 +09:00 (Migrated from gitlab.com)

I found this behaviour in aesophia_cli, but probably it is related to the whole compiler.

Reproduction.aes

contract interface RemoteI =
  datatype event = RemoteEvent(int)
  entrypoint emitEvents : () => unit

contract Test =
  datatype event = Event(int)
  stateful entrypoint emitEvents(remote: RemoteI) : unit =
    Chain.event(Event(42))
    remote.emitEvents()
$ ./aesophia_cli --version                           
Sophia compiler version 7.4.0
$ ./aesophia_cli ./Reproduction.aes       
Warning in './Reproduction.aes' at line 2, col 3:
The type `event` is defined but never used.
cb_+OJGA6A8lEFdU+Y5bIcB/Y6CFyjQhDCni5at80+U1cCLiLmvDcC4tbiC/kTWRB8ANwA3ABoOgj8BAz/+ZaXgDwI3AYcBNwEHNwBGNgAAAGIvX58BgR9CGdutZoszd/R2GZyVS+3JJy1C+hSzitoW5feMmcSnAAEDP/7hKsRXADcBRwI3AAwDrwEAG1QCAxFlpeAPDwJvgibPDAMADAEAAwD8EeEqxFc3ADcAAK0vAxFE1kQfEWluaXQRZaXgDy1DaGFpbi5ldmVudBHhKsRXKWVtaXRFdmVudHOCLwCFNy40LjAAifgV3g==

I'm using this kind of contract to generate ACI. The event type provided in ACI is used to decode events emitted by emitEvents. I doubt that the compiler should warn about this.

I found this behaviour in aesophia_cli, but probably it is related to the whole compiler. Reproduction.aes ``` contract interface RemoteI = datatype event = RemoteEvent(int) entrypoint emitEvents : () => unit contract Test = datatype event = Event(int) stateful entrypoint emitEvents(remote: RemoteI) : unit = Chain.event(Event(42)) remote.emitEvents() ``` ``` $ ./aesophia_cli --version Sophia compiler version 7.4.0 $ ./aesophia_cli ./Reproduction.aes Warning in './Reproduction.aes' at line 2, col 3: The type `event` is defined but never used. cb_+OJGA6A8lEFdU+Y5bIcB/Y6CFyjQhDCni5at80+U1cCLiLmvDcC4tbiC/kTWRB8ANwA3ABoOgj8BAz/+ZaXgDwI3AYcBNwEHNwBGNgAAAGIvX58BgR9CGdutZoszd/R2GZyVS+3JJy1C+hSzitoW5feMmcSnAAEDP/7hKsRXADcBRwI3AAwDrwEAG1QCAxFlpeAPDwJvgibPDAMADAEAAwD8EeEqxFc3ADcAAK0vAxFE1kQfEWluaXQRZaXgDy1DaGFpbi5ldmVudBHhKsRXKWVtaXRFdmVudHOCLwCFNy40LjAAifgV3g== ``` I'm using this kind of contract to generate ACI. The event type provided in ACI is used to decode events emitted by `emitEvents`. I doubt that the compiler should warn about this.
ghallak commented 2023-11-21 02:02:02 +09:00 (Migrated from gitlab.com)

@davidyuk Why do you think this is a bug?

The warning is shown because neither the datatype event nor the data constructor RemoteEvent(int) are used.

@davidyuk Why do you think this is a bug? The warning is shown because neither the datatype `event` nor the data constructor `RemoteEvent(int)` are used.
ghallak commented 2023-11-27 18:13:00 +09:00 (Migrated from gitlab.com)

Closing this as it's the expected behavior and it's not a real bug.

Closing this as it's the expected behavior and it's not a real bug.
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#491
No description provided.