ash-project / ash-project/igniter

In "Desired/Found", using `quote` inside `add_dep` is printing the AST

Open
#338 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Elixir
Stars
404
Forks
75
Avg merge
9h 58m
Merged PRs (30d)
3

Description

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

### AI Policy

- [x] I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

### Versions

Elixir: 1.18.4
Erlang: 27

### Operating system

Ubuntu inside Windows WSL

### Current Behavior

Trying to update dependency with `add_dep` like this:

```elixir
|> Igniter.Project.Deps.add_dep(
{:esbuild, "~> 0.10", runtime: quote(do: Mix.env() == :dev)},
)
```

# Current behaviour

In "Desired" and "Found", we get this:

```
Desired: `{:esbuild, "~> 0.10", [runtime: {:==, [context: Phoenix.LiveView.Igniter.UpgradeTo1_1, imports: [{2, Kernel}]], [{{:., [], [{:__aliases__, [alias: false], [:Mix]}, :env]}, [], []}, :dev]}]}`
Found: `{:esbuild, "~> 0.8", [runtime: true]}`
```

For "Desired", the AST of `quote(do: Mix.env() == :dev)` is printed.

For "Found", `Mix.env() == :dev` has been evaluated.

# Expected behaviour

Here is what we should have in best case:
```
Desired: `{:esbuild, "~> 0.10", runtime: Mix.env() == :dev}`
Found: `{:esbuild, "~> 0.8", runtime: Mix.env() == :dev}`
```

# Related PR

Related to https://github.com/phoenixframework/phoenix_live_view/pull/4011#discussion_r2404460540

### Reproduction

Trying to update a dependency with `add_dep` like this:

```elixir
|> Igniter.Project.Deps.add_dep(
{:esbuild, "~> 0.10", runtime: quote(do: Mix.env() == :dev)},
)
```

Dedicated branch with the issue in a fork of `phoenix_live_view`: https://github.com/phoenixframework/phoenix_live_view/compare/main...aifrak:phoenix_live_view:igniter-issue-add-deps

### Expected Behavior

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at Igniter.Project.Deps.add_dep and reproduce the issue using the dedicated branch linked in the report. Trace how the Desired and Found dependency options are rendered, especially the quoted runtime expression; done means both outputs preserve the intended expression instead of showing an AST or an evaluated value.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.