starkware-libs / cairo

Cairo is the first Turing-complete language for creating provable programs for general computation.
Apache License 2.0
1.61k stars 499 forks source link

bug: `handle_main_return_value` cannot return a ByteArray #6468

Open enitrat opened 1 month ago

enitrat commented 1 month ago

Bug Report

Cairo version: 2.8.4

Current behavior: https://github.com/starkware-libs/cairo/blob/d7813fb076008a9124c78a0c7cb60bae9e17d767/crates/cairo-lang-runner/src/lib.rs#L480-L509

Where a println! would print: [1, 2, 3, 420], the returned values are [0x1e50, 0x1e50, 0x225b312c20322c20332c203432305d22, 0x10]

It seems that bytearrays, and in general, any pointer-based struct, cannot be returned.

Expected behavior: This should return the serialized bytearray representation for the above, which would be [0, 0x225b312c20322c20332c203432305d22, 0x10]

orizi commented 1 month ago

what are you trying to use it for? note that this is a structure for only for debug and test runs for the time being - not for actual provable calculation.

enitrat commented 1 month ago

A custom test runner. I use cairo-run to output JSON representations of my types as bytearrays. The goal is to use this test runner for property testing / diff testing