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

Compiler fails sometimes when parameter deconstruction not used #83

Open
trosos opened this issue Mar 19, 2022 · 1 comment
Open

Compiler fails sometimes when parameter deconstruction not used #83

trosos opened this issue Mar 19, 2022 · 1 comment
Assignees

Comments

@trosos
Copy link

trosos commented Mar 19, 2022

I believe that I maybe found a bug in the compiler.

Steps to reproduce:

cat > puzzle.cl <<EOF
(mod params
 (defun ident (arg)
  (f (list arg))
 )

 (ident (ident params))
)
EOF

run puzzle.cl

Expected result:

I expect a CLVM puzzle to be written to stdout, which would output its solution when passed to brun (i.e. "identity puzzle").

Actual results:

The run command fails with the following message:

FAIL: first of non-cons 1

Some more insight:

When I modify the puzzle in either one of the following ways, then it translates and the resulting CLVM behaves as expected:

  1. (f (list arg)) -> (f arg)
  2. (f (list arg)) -> (list arg)
  3. (f (list arg)) -> (f (f arg))
  4. (f (list arg)) -> (list (list arg))
  5. (f (list arg)) -> (list (f arg))
  6. (ident (ident params)) -> (ident params)
  7. (mod params ...) -> (mod (params) ...)

Please note that the documentation admits any of the following possibilities:

  • (mod params ...)
  • (mod (param_one param_two) ...)
  • (mod ((param)) ...)

Quoting https://chialisp.com/docs/high_level_lang#squaring-a-list:

You can name each parameter in a list or you can name the list itself. This works at any place where you name parameters, and allows you to handle lists where you aren't sure of the size.

prozacchiwawa added a commit to Chia-Network/clvm_tools_rs that referenced this issue Aug 23, 2022
@prozacchiwawa
Copy link
Contributor

thanks i have a candidate fix for this
fairly certain it's a stray bug introduced in the conversion to rust
pr: Chia-Network/clvm_tools_rs#65

wallentx pushed a commit to Chia-Network/clvm_tools_rs_fork that referenced this issue Sep 26, 2022
* candidate fix for Chia-Network/clvm_tools#83

* Update for now-absent build products

* Add a test that compiles and runs the user's program from the github issue: a fancy way of doing 'ident' on an un-destructured module argument.  the expected result is the full env we give

* Add unit test for un-destructured args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants