So, normally I like to restrict my alias scopes as little as possible, so instead of adding an alias in the top of a file, I prefer to do it inside a code block.
On older versions of Ash, adding the following code:
policies do
alias Marketplace.Markets.Checks, as: MarketsChecks
policy action([:place_offer]) do
forbid_if MarketsChecks.NotConfirmedYet
forbid_unless MarketsChecks.IsInvestor
authorize_if always()
end
end
Will work fine, but using the latest version, now it gives me the following warning during compilation:
warning: unused alias MarketsChecks
lib/marketplace/markets/offer.ex:80
Note that even with the warning, the policy above still works fine.
Is it a easy fix to make this warning go away? I do the same in other code blocks (relationships, calculations, attributes, etc) and they all work fine, I’m only seeing this on the policies block
Removing the as option fixed it. But, if possible, I would like to keep it since I added that because it conflicts with another alias that has the same name Checks
Yeah, that makes sense. We made a special thing to avoid these issues, and I suspect it isn’t properly handling as aliases . Can you open an issue in spark? In the meantime, you can use the alias you want but add , warn: false option.