WolframResearch / wstp-rs

Rust bindings to the Wolfram Symbolic Transport Protocol (WSTP)
Apache License 2.0
21 stars 3 forks source link

Mismatched Types in wstp-0.2.7 #51

Closed ben-izd closed 1 year ago

ben-izd commented 1 year ago

Compiling the new version led to the following errors on my platform (Windows 11, Mathematica 13.2.1, Rust 1.67)

error[E0308]: mismatched types
   --> C:\ ... \wstp-0.2.7\src\lib.rs:306:15
    |
306 |         code: sys::WSTerminateMessage,
    |               ^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`

error[E0308]: mismatched types
   --> C:\ ... \wstp-0.2.7\src\lib.rs:312:15
    |
312 |         code: sys::WSInterruptMessage,
    |               ^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`

error[E0308]: mismatched types
   --> C:\ ... \wstp-0.2.7\src\lib.rs:318:15
    |
318 |         code: sys::WSAbortMessage,
    |               ^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`

error[E0308]: mismatched types
   --> C:\ ... \wstp-0.2.7\src\lib.rs:344:13
    |
343 |         let kind = match code {
    |                          ---- this expression has type `u32`
344 |             sys::WSTerminateMessage => UrgentMessageKind::Terminate,
    |             ^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`

error[E0308]: mismatched types
   --> C:\ ... \wstp-0.2.7\src\lib.rs:345:13
    |
343 |         let kind = match code {
    |                          ---- this expression has type `u32`
344 |             sys::WSTerminateMessage => UrgentMessageKind::Terminate,
345 |             sys::WSInterruptMessage => UrgentMessageKind::Interrupt,
    |             ^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`

error[E0308]: mismatched types
   --> C:\ ... \wstp-0.2.7\src\lib.rs:346:13
    |
343 |         let kind = match code {
    |                          ---- this expression has type `u32`
...
346 |             sys::WSAbortMessage => UrgentMessageKind::Abort,
    |             ^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`

error[E0308]: mismatched types
   --> C:\ ... \wstp-0.2.7\src\lib.rs:358:45
    |
356 |     pub fn code(&self) -> u32 {
    |                           --- expected `u32` because of return type
357 |         match self {
358 |             UrgentMessageKind::Terminate => sys::WSTerminateMessage,
    |                                             ^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`
    |
help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit
    |
358 |             UrgentMessageKind::Terminate => sys::WSTerminateMessage.try_into().unwrap(),
    |                                                                    ++++++++++++++++++++

This can be solved by simply casting but I couldn't test the last LibraryLink example, as Mathematica would crash. Is there any incompatibility?

ConnorGray commented 1 year ago

@ben-izd Thanks for bringing this issue to my attention.

This fix has been released as part of v0.2.8 of wstp and wstp-sys, which I've just published.