Re: [elixir-core:11740] Better error message for unknown variables inside macros that haven't been required

2024-04-02 Thread José Valim
We have a record that controls compilation: https://github.com/elixir-lang/elixir/blob/main/lib/elixir/src/elixir.hrl#L8 You are going to add a new field called "debug". This field can have three values: * enabled * disabled * pending Whenever we raise because of an undefined variable, we will

Re: [elixir-core:11739] Better error message for unknown variables inside macros that haven't been required

2024-04-02 Thread Zach Daniel
Sounds good! I’ll open one now. I’m also happy to investigate adding this, but will need a nudge as to where to start looking. Not high priority, but I think will be a great quality of life improvement for users. > On Apr 2, 2024, at 5:40 PM, José Valim wrote: > > We could try that. Please ope

Re: [elixir-core:11738] Better error message for unknown variables inside macros that haven't been required

2024-04-02 Thread José Valim
We could try that. Please open up an issue so we don't forget about it. :) On Tue, Apr 2, 2024 at 11:36 PM Zach Daniel wrote: > Could we potentially do something only in the case that we reach this > error? Like if a module fails to compile with an undefined variable error, > we could attempt to

Re: [elixir-core:11737] Better error message for unknown variables inside macros that haven't been required

2024-04-02 Thread Zach Daniel
Could we potentially do something only in the case that we reach this error? Like if a module fails to compile with an undefined variable error, we could attempt to compile it again with some metadata set that tells the compiler that it should check on remote calls if the module is available and

Re: [elixir-core:11736] Better error message for unknown variables inside macros that haven't been required

2024-04-02 Thread José Valim
Unfortunately this is hard. The simplest way to implement this would be by checking on every remote call if the module is available and if the function is macro, which would considerably slow down the compiler. The reason why we have "require" is exactly so we don't need to pay this price. We could

Re: [elixir-core:11735] [Proposal] introduce with_env in ExUnit

2024-04-02 Thread Jason Axelson
> But as an alternative approach for your use case: you could implement a simple wrapper function around `System.get_env` (etc.) that reads/writes to a special key in the process dictionary, falling through to calling the `System` APIs if the process dictionary doesn't have the `:env` key (or whate

Re: [elixir-core:11735] [Proposal] Translate error reports from gen_statem

2024-04-02 Thread Cameron Duley
PR here: https://github.com/elixir-lang/elixir/pull/13451. On Wednesday, March 27, 2024 at 5:17:17 PM UTC-4 José Valim wrote: > I would love to see a PR that implements translation for gen_statem, so we > can evaluate if it makes sense to merge it into Elixir. > > On Wed, Mar 27, 2024 at 4:10 PM

[elixir-core:11735] Better error message for unknown variables inside macros that haven't been required

2024-04-02 Thread Zach Daniel
Hey all! Something that happens very often to Ash users is forgetting to do something like `require Ash.Query`, and then doing something like this: ``` Ash.Query.filter(Resource, name == "fred") ``` Then, they get an error like `error: undefined variable "name"` What I'm wondering is if we can