Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some operators can no longer operate on py-atoms upwards of hyperon-0.2.2 #881

Open
JungeWerther opened this issue Mar 7, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@JungeWerther
Copy link

Describe the bug

Previously (confirmed to work in 0.2.1) you could do:

!(bind! now (py-atom datetime.datetime.now))
(= (A) (now))
(= (B) (now))
!(- (A) (B))

The - sign would point to the python infix operator -. However, in 0.2.3 for example, I get the following error:

thread '<unnamed>' panicked at lib/src/atom/serial.rs:65:56:
ConvertingSerializer is not expected returning error: NotSupported
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread '<unnamed>' panicked at library/core/src/panicking.rs:218:5:
panic in a function that cannot unwind
stack backtrace:
   0:     0x7d5e64b7535a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he089f96442833f67
   1:     0x7d5e64bc48d3 - core::fmt::write::h2f210ed4c94745cb
   2:     0x7d5e64b69673 - <unknown>
   3:     0x7d5e64b751a2 - <unknown>
   4:     0x7d5e64b77880 - <unknown>
   5:     0x7d5e64b77660 - std::panicking::default_hook::h24e207139139d40a
   6:     0x7d5e64b78052 - std::panicking::rust_panic_with_hook::ha9131beeb2ddc506
   7:     0x7d5e64b77dc6 - <unknown>
   8:     0x7d5e64b75859 - std::sys::backtrace::__rust_end_short_backtrace::h1d1ca3eade483f4c
   9:     0x7d5e64b77a8d - rust_begin_unwind
  10:     0x7d5e64770b2d - core::panicking::panic_nounwind_fmt::h0d5ff668f956fac4
  11:     0x7d5e64770bc2 - core::panicking::panic_nounwind::h385b7d9bda51382d
  12:     0x7d5e64770d86 - core::panicking::panic_cannot_unwind::h757b6ea37bf9b60a
  13:     0x7d5e647b08cf - metta_run
  14:     0x7d5e64795138 - <unknown>
  15:     0x7d5e6477b6de - <unknown>
  16:           0x58208f - <unknown>
  17:           0x549185 - _PyObject_MakeTpCall
  18:           0x5d73c9 - _PyEval_EvalFrameDefault
  19:           0x5d58eb - PyEval_EvalCode
  20:           0x608b42 - <unknown>
  21:           0x6b4e93 - <unknown>
  22:           0x6b4bfa - _PyRun_SimpleFileObject
  23:           0x6b4a2f - _PyRun_AnyFileObject
  24:           0x6bca95 - Py_RunMain
  25:           0x6bc57d - Py_BytesMain
  26:     0x7d5e6582a1ca - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  27:     0x7d5e6582a28b - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:360:3
  28:           0x657ce5 - _start
  29:                0x0 - <unknown>

To Reproduce
Steps to reproduce the behavior:
pip install hyperon-0.2.3 then run the above script with metta

Expected behavior
Expected result:

[(datetime.timedelta(microseconds=1337)]

Actual behavior
The program crashes, the atoms are not evaluated. When used in a nested expression, for example

(= (measure $expression) (
  let $start-time (now) (
    ($expression)
    (- (now) $start-time)))
)

the rust exception will be obfuscated, while the program does not execute past the point of failure.

Additional context

  • MeTTa version: 0.2.3
@vsbogd
Copy link
Collaborator

vsbogd commented Mar 8, 2025

Same issue about incompatibilities after upgrading to 0.2.2: see example 4 at https://github.com/trueagi-io/metta-lang-dev/issues/90 .

This is a work in progress @besSveta and me are working on changing modules system to allow overriding Rust arithmetics operators in a Python standard library.

@vsbogd vsbogd added the bug Something isn't working label Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants