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

Generic Printer: ~constructor argument to expr'_Construct_inductive is wrong for structs #1295

Open
keks opened this issue Feb 6, 2025 · 0 comments
Labels
engine Issue in the engine

Comments

@keks
Copy link
Member

keks commented Feb 6, 2025

When processing these assignments

self.pl_value = msg.vm_value;
self.pl_last_changed = msg.vm_timestamp;

this function in the generic printer implementation

method expr'_Construct_inductive ~super ~constructor ~is_record:_
~is_struct ~fields ~base:_ =
let constructor = if is_struct
then constructor#p
else constructor#p in
let constructor = sexprlist [string "as" ; constructor; self#print_ty AstPos_expr__e super.typ] in
if (List.is_empty fields)
then constructor
else sexprlist (constructor :: ps (List.map ~f:(fun (name, expr) -> expr ) fields))

(please ignore the pointless if-then-else 🙈 )

produces this code

(let
      (
        (self
          (
            (as validation_example/t_ProtocolLibrary validation_example/t_ProtocolLibrary)
            (get/validation_example/f_vm_value msg))))
      (let
        (
          (self
            (
              (as validation_example/t_ProtocolLibrary validation_example/t_ProtocolLibrary)
              (get/validation_example/f_vm_timestamp msg))))
        (let
          (
            (hax_temp_output
              (
                (as
                  core/result/Result_Ok
                  (core/result/t_Result Tuple0 validation_example/t_Error))
                (mk-tuple0))))
          (mk-tuple2 self hax_temp_output))))

Specifically, look at the type coercion that the ocaml code above builds:

(as validation_example/t_ProtocolLibrary validation_example/t_ProtocolLibrary)

This should be

(as <constructor_name> <type_name>

I think this is because the constructor and type name are not properly separated in some parts of the engine.

@keks keks added the engine Issue in the engine label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine Issue in the engine
Projects
None yet
Development

No branches or pull requests

1 participant