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

TC: support non-literal defconst values and fix generated Infos for consts #1115

Closed
sirlensalot opened this issue Jan 9, 2023 · 1 comment · Fixed by #1116
Closed

TC: support non-literal defconst values and fix generated Infos for consts #1115

sirlensalot opened this issue Jan 9, 2023 · 1 comment · Fixed by #1116

Comments

@sirlensalot
Copy link
Contributor

As seen in #1105 , but the actual bug driving the change is still open:

pact> (verify 'coin)
<interactive>:1:0: : Native in value context: ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19"]

It's hard to track this down because there is no Info on the term; this is because the offending code --

  (defconst VALID_CHAIN_IDS (map (int-to-str 10) (enumerate 0 19))
    "List of all valid Chainweb chain ids")

-- populates the value from applying a native at module load. Generally runtime-generated values do not have code locations, but in the defconst case it would be useful to supply them perhaps by overwriting the Info value with the old code location.

The actual bug is the typechecker cannot handle non-literals in consts since these are Direct ref values. To fix either specifically handle lists, or investigate whether to just recurse back to toAST and stop the special-casing for Direct.

@sirlensalot
Copy link
Contributor Author

Indeed if we replace (map ... enumerate ...) with the literal ["0" ... "19"] the output becomes:

*** Exception: ../chainweb/pact/coin-contract/v5/coin-v5.pact:160:28: Native in value context: ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19"]

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

Successfully merging a pull request may close this issue.

1 participant