At7heb

At7heb

My mistake: I had two “use Ash.Domain” lines in my file – the second one to add “AshAdmin.Domain”.

The error message was misleading to me. The message indicated the problem was with the “defmodule” line.

My wish: the error message was more along the lines of “don’t repeat ‘use Ash.Domain’ in the same file”

Suggestion: the error message should indicate the problem is in the second “use Ash.Domain” line instead of the “defmodule …” line.

Here’s the error I got

heb@howards-mbp ogl % mix compile
Compiling 3 files (.ex)
    error: def can?/3 defines defaults multiple times. Elixir allows defaults to be declared once per definition. Instead of:

        def foo(:first_clause, b \\ :default) do ... end
        def foo(:second_clause, b \\ :default) do ... end

    one should write:

        def foo(a, b \\ :default)
        def foo(:first_clause, b) do ... end
        def foo(:second_clause, b) do ... end

    │
  1 │ defmodule Ogl.Lesson do
    │ ^^^^^^^^^^^^^^^^^^^^^^^
    │
    └─ lib/ogl/lesson.ex:1


== Compilation error in file lib/ogl/lesson.ex ==
** (CompileError) lib/ogl/lesson.ex: cannot compile file (errors have been logged)
    /Users/heb/dev/ogl/lib/ogl/lesson.ex:1: (file)
    (stdlib 6.1) erl_eval.erl:904: :erl_eval.do_apply/7
    (stdlib 6.1) erl_eval.erl:271: :erl_eval.exprs/6
    (stdlib 6.1) erl_eval.erl:436: :erl_eval.expr/6
    (spark 2.2.27) /Users/heb/dev/ogl/lib/ogl/lesson.ex:1: Spark.Dsl.__before_compile__/1

Showing Posts 1 to 5

zachdaniel

zachdaniel

Creator of Ash

Yeah, this is pretty interesting. I imagine that pretty much any module that defines a use like this does not anticipate being used twice :laughing: since it’s a code mix in like that. It wouldn’t be a high priority, but would be relatively easy to detect so makes sense to add. Could you open an issue on the ash repo?

At7heb

At7heb OP

Done.

I don’t have a good sense of when I can and when I can’t repeat a macro call. E.G. in router.ex, multiple scope "/" do lines are acceptable.

At7heb

At7heb OP

I would hate to start a bunch of stuff like the C header stuff

#ifndef __MYHEADERNAME__
ext bool global_bool;
#define __MYHEADERNAME__
#endif
zachdaniel

zachdaniel

Creator of Ash

99.9% of the time, a use macro is meant to be performed only once.

At7heb

At7heb OP

I should have figured that out.

Quoting Peter, Paul, and Mary, “I’ll learn so that my later days will be prosperous…”

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews