typed-racket
typed-racket copied to clipboard
"Unable to protect opaque value" Warning for values of opaque type
What version of Racket are you using?
v7.8
What program did you run?
#lang typed/racket
(require/typed/provide ffi/unsafe
;; Opaque Types
[#:opaque CType ctype?]
;; Numeric Types
[_int8 CType]
[_sint8 CType]
[_uint8 CType]
[_int16 CType]
[_uint16 CType]
[_sint16 CType]
[_int32 CType]
[_uint32 CType]
[_sint32 CType]
[_int64 CType]
[_uint64 CType]
[_sint64 CType]
[_byte CType]
[_sbyte CType]
[_ubyte CType]
[_wchar CType]
[_word CType]
[_sword CType]
[_uword CType]
[_short CType]
[_sshort CType]
[_ushort CType]
[_int CType]
[_sint CType]
[_uint CType]
[_long CType]
[_slong CType]
[_ulong CType]
[_llong CType]
[_sllong CType]
[_ullong CType]
[_intptr CType]
[_sintptr CType]
[_uintptr CType]
[_size CType]
[_ssize CType]
[_ptrdiff CType]
[_intmax CType]
[_uintmax CType]
[_fixnum CType]
[_ufixnum CType]
[_fixint CType]
[_ufixint CType]
[_float CType]
[_double CType]
[_double* CType]
[_longdouble CType]
;; Other Atomic Types
[_stdbool CType]
[_bool CType]
[_void CType]
;; String Types
[_string/ucs-4 CType]
[_string/utf-16 CType]
[_path CType]
[_symbol CType]
[_string/utf-8 CType]
[_string/latin-1 CType]
[_string/locale CType]
[_string*/utf-8 CType]
[_string*/latin-1 CType]
[_string*/locale CType]
[_string CType]
[_file CType]
[_bytes/eof CType]
[_string/eof CType]
;; Pointer Types
[_pointer CType]
[_gcpointer CType]
[_racket CType]
[_scheme CType]
[_fpointer CType])
What should have happened?
The values of an opaque type should not trigger a contract violation, I assume.
If you got an error message, please include it here.
(This is a warning message, but a confusing one, so I'm including it.)
ctype?: contract violation
any-wrap/c: Unable to protect opaque value passed as `Any`
value: #<ctype:int8>
This warning will become an error in a future release.
in: the 1st argument of
a part of the or/c of
(or/c
struct-predicate-procedure?/c
(-> Any boolean?))
contract from: (interface for ctype?)
blaming: /home/rana.js/Desktop/typed-ffi-unsafe.rkt
(assuming the contract is correct)
This warning appears for each CType value (aot procedure, parameter, etc) in the require-specs. Only the value: message changes.
Note
This does not halt the REPL. It appears to be a deprecation warning. If so, the documentation should be revisited.
真是巧了,v8.16也有同样问题。 看来ts不是很支持FFI。