Julia compute_all_bincode always throws MethodError: the parameter named 'length' shadows Base.length

Aperta Adatta ai principianti
#232 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
92/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
julia, rust

Direzione di ricerca

Inizia in bindings/julia/src/ffi.jl presso compute_all_bincode, alle righe 348-352, e conferma che il suo parametro length nasconda Base.length. Aggiorna la chiamata length(terms) oppure rinomina il parametro, quindi esegui la riproduzione Julia usando RSSN.compute_all_bincode per verificare che restituisca un record bincode Vector{UInt8}; controlla compute_bincode alla riga 345 per lo stesso schema di shadowing.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area/api-bindings help wanted kind/panic severity/3-major

RSSN.compute_all_bincode throws MethodError for every input, because its ccall helper names a parameter length, which shadows Base.length.

using RSSN
s = RSSN.Session()
RSSN.compute_all_bincode(s, ["1+1", "diff(x^2,x)"])
# ERROR: MethodError: objects of type Base.RefValue{UInt64} are not callable.
#  [1] compute_all_bincode(ptr::Ptr{Nothing}, terms::Vector{UInt32}, config::Ptr{Nothing},
#                          out::Base.RefValue{Ptr{UInt8}}, length::Base.RefValue{UInt64})
#      @ RSSN D:\rssn\bindings\julia\src\ffi.jl:350

The offending definition is bindings/julia/src/ffi.jl:348-352:

compute_all_bincode(ptr::Ptr{Cvoid}, terms::Vector{UInt32}, config::Ptr{Cvoid},
                    out::Base.RefValue{Ptr{UInt8}}, length::Base.RefValue{Csize_t}) =
    ccall(_sym(:rssn_compute_all_bincode), Cint,
          (Ptr{Cvoid}, Ptr{UInt32}, Csize_t, Ptr{Cvoid}, Ptr{Ptr{UInt8}}, Ptr{Csize_t}),
          ptr, Base.pointer(terms), length(terms), config, out, length)

length(terms) inside the body resolves to the new parameter (a RefValue), not Base.length, so it tries to call the RefValue. compute_bincode on line 345 has the same shadowing but never calls length(...), so it is unaffected.

The function is exported (RSSN.jl:66), so the public batch-bincode API is unusable. The Python binding returns the expected record for the same kernel call:

s.compute_all_bincode(["1+1", "diff(x^2,x)"])   # 46 bytes

Expected: Vector{UInt8} containing the bincode-next record. Fix: Base.length(terms), or rename the parameter to out_len.

rssn 0.3.0, Julia binding, Windows x86_64.

Lingua principale
Rust
Stelle
36
Fork
3
Merge medio
14h 51m
PR unite (30g)
29

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Apich-Organization/rssn

Tutte le issue di Apich-Organization/rssn

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.