kadena-io / pact

The Pact Smart Contract Language
https://docs.kadena.io/build/pact
BSD 3-Clause "New" or "Revised" License
579 stars 100 forks source link

FV: str-to-int doesn't parse #1303

Closed EnoF closed 11 months ago

EnoF commented 11 months ago

Issue description

When running:

(module test G
  (defcap G() true)

  (defun test(name:string) 
    @model [
      (property (> (str-to-int 64 name) 0))
    ]
    (str-to-int 64 name)
  )
)

(verify 'test)

I get the the following error:

:OutputFailure: /home/enof/repl-tests/str-to-int.repl:6:16: could not parse (> (str-to-int 64 name) 0): in 64, type error: string vs integer (CallStack (from HasCallStack):   typeError, called at src-tool/Pact/Analyze/Parse/Prop.hs:758:22 in pact-4.7.1-2Oc0sGL4MAOGhXKFdO8UkI:Pact.Analyze.Parse.Prop)
****

The following code also doesn't work:

(module test G
  (defcap G() true)

  (defun test(name:string) 
    @model [
      (property (> (str-to-int name) 0))
    ]
    (str-to-int 64 name)
  )
)

(verify 'test)

I get the following error:

/home/enof/repl-tests/str-to-int.repl:7:16:OutputFailure: Invalid model failure:
  Program trace:
    entering function test.test with argument
      name = "/home/enof/repl-tests/str-to-int.repl:1:0:Error: load: file load failed: /home/enof/repl-tests/str-to-int.repl, <stderr>: hPutChar: invalid argument (cannot encode character '\154')
Load failed

Steps to reproduce

Expected Behavior

Debug Information

rsoeldner commented 11 months ago

@EnoF good catch, thank you. I opened a PR to fix the parsing.