Skip to content

Fix rescue expansion for __MODULE__ and __DIR__ - #16202

Open
lukaszsamson wants to merge 1 commit into
elixir-lang:mainfrom
lukaszsamson:codex/fix-rescue-module-expansion
Open

lukaszsamson wants to merge 1 commit into
elixir-lang:mainfrom
lukaszsamson:codex/fix-rescue-module-expansion

Conversation

@lukaszsamson

Copy link
Copy Markdown
Contributor

Expand bare __MODULE__ as an exception module and report invalid rescue clauses for bare __DIR__ or either macro on the left of in _.

Assisted-by: Codex:GPT-6

@@ -455,7 +455,14 @@ expand_rescue(Meta, _, _, E) ->

%% rescue var
expand_rescue({Name, Meta, Atom} = Var, S, E) when is_atom(Name), is_atom(Atom) ->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in #16198, I'd probably prefer to be explicit and reject all of MODULE, CALLER, and so on upfront. Perhaps we should have all of the names defined in elixir.hrl so we can reuse them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this works:

try do
...
rescue
e in __MODULE__ -> ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So everything BUT module?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants