aiken-lang / aiken

A modern smart contract platform for Cardano
https://aiken-lang.org
Apache License 2.0
486 stars 98 forks source link

UPLC is not able to parse data in complex constant #777

Closed nielstron closed 11 months ago

nielstron commented 11 months ago

What Git revision are you using?

aiken v1.0.21-alpha+b25e82e

What operating system are you using, and which version?

Describe what the problem is?

The following program fails to parse in aiken

(program 1.0.0 (con (list (pair data data)) [((B #), (I 0))]))
Error:   × error at 1:51: expected one of ['a' ..= 'z' | 'A' ..= 'Z' | '0' ..= '9' | '_' | '\''], found 'Data' instead of expected type

What should be the expected behavior?

Should correctly parse.

nielstron commented 11 months ago

Further examples

(program 1.0.0 (con (list data) [(B #00)]))
(program 1.0.0 (con (pair data data) [(B #00), (I 0)]))
(program 1.0.0 (con (pair data data) ((B #00), (I 0))))

Meanwhile, the following parse

(program 1.0.0 (con data (B #)))
(program 1.0.0 (con data (I 0)))
(program 1.0.0 (con (pair data data) (B #00, I 0)))

It is not entirely clarified in https://github.com/input-output-hk/plutus/issues/4751#issuecomment-1538377273 since the examples kind of contradict the syntax definition in these cases - but I would argue that both surrounding by parentheses and not should be fine? Other than that one could also argue that the last presented line (B #00, I 0) is actually ambiguous - it could be either a pair of data or a data pair, which is unfortunately not equivalent (the latter only occuring in plutus maps)

nielstron commented 11 months ago

According to the uplc executable provided in newer releases of the plutus repo, the syntax implemented in aiken is the correct one. The python package has been adjusted accordingly.