archethic-foundation / archethic-foundation/archethic-node

Interpreter error message not clear

Open
#1,131 0 comments 0 reactions 0 assignees View on GitHub
bug smart contracts
Dominant language
Elixir
Stars
82
Forks
24
PR merge metrics
No merged PRs in 30d

Description

### Describe the problem you discovered

If we pass a smart contract code with just the following code:

```elixir
@version 1
```

We get an error which is not accurate:

```
unexpected term - @:atom => \"version\"(1) - L1
```

This issue seems to related to a pattern matching issue

https://github.com/archethic-foundation/archethic-node/blob/31cc63def92a24b74a5133f3c8f19a7d3e9a7886/lib/archethic/contracts/interpreter.ex#L36C10-L38C44

### Describe the solution you'd like

The interpreter should accept @version 1 without having a block or mention the contract cannot be empty with only the version mention.

### Epic

#608

Contributor guide

Open the contributing guide

Research direction

Start in lib/archethic/contracts/interpreter.ex at the linked lines 36-38 and reproduce the error with a contract containing only @version 1. Trace the pattern-matching path that produces the inaccurate message, then verify that the interpreter either accepts this declaration without a block or reports clearly that the contract cannot contain only the version declaration.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
blockchain, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.