Onor.io

Onor.io

Do you agree libraries should include warning IDs?

I apologize in advance if this has been suggested by others but here goes.

Just today I was compiling some code and once again I’m presented with scads of warnings generated by libraries. So I thought to myself, “Gosh I wish I had a pragma that I could use to silence warnings from libraries. Or even be able to silence a specific warning.” But then it occurred to me that the warnings I’m seeing don’t seem to have any sort of ID associated with them so I’ve got an all or nothing situation. I mean I could either silence all warnings regardless of source or I can’t silence any of them.

So, assuming there are no warning ids, could we start associating ID’s with warnings to allow for the later use of a pragma mechanism to silence specific warnings?

For example I get the following warning from absinthe (and I realize I may not be up to date on my version):

warning: using map.field notation (without parentheses) to invoke function Absinthe.Type.BuiltIns.DeprecatedDirectiveFields.absinthe_blueprint() is deprecated, you must add parentheses instead: remote.function()

Is there an id associated with this warning? I mean I don’t see any id in the text. Let’s say I wanted to silence this warning because I cannot upgrade Absinthe. There’s no way to silence the warning because I can’t specifically identify it. If it had some id (e. g. W001) then I might be able to do something like:

Code.pragma_silence_warning([“W001”])

or something along those lines.

I’m not sure that I am explaining my thinking very well here but I hope others will understand what I’m getting at. I mean I don’t think we can selectively silence warnings or do much of anything with them until they have ids or some identification mechanism associated with them.

I’d appreciate any thoughts from others if anyone cares to weigh in on this.

Most Liked

garazdawi

garazdawi

Erlang Core Team

EEP-74 describes a solution for doing this. If/When implemented, it would be used by all languages running on top of Erlang. Though each compiler would have to implement support for emitting/silencing the warnings.

PR-10032 is a first step in adding this to the Erlang compiler though, as you can see in the comments, it is currently stalled.

12
Post #6
mudasobwa

mudasobwa

Creator of Cure

Huh? The strongly-identified warning is not an ID associated with it, but rather ID+location/code snippet pair. I like the idea of identifying the warnings by ID, but for God’s sake let’s do it properly. The ID as per Rust/TS is nothing but a cludge. There is not much sense in having a short alias for a warning, specifically in the era of machines reading the code. The ID+snippet allows addressing, sharing, and even debugging without a context.

Joe Armstrong has proposed the very same thing for the whole internet once.

christhekeele

christhekeele

Strongly-identified warnings are common in Typescript and Rust, but only at the language compiler level. This is possible to implement via discipline and convention alone. I like them a lot, and Elixir could do similar, but that only gets us part of the way there. You’re asking for library-level warning ids, which requires tooling in the stdlib for registering ids across dependencies, emitting strongly-identified warnings separately from/alongside normal logger configuration mechanisms, then suppressing them. It’d be a big lift!

Worth noting that you can silence warnings today at the dependency, module, and function level already via compile_time_purge_matching. This ability is strictly more flexible than what you propose, but lacks the ability to semantically recognize a warning across changes in dependency versions. I’d argue it’s still better, because a semantically similar warning (with the same “id”) might be omitted from a new codepath in a library in a future version, and you wouldn’t want your existing code to suppress it.

Where Next?

Popular in Dev Env & Tools Top

pjbs
Mechanical? Which Cherry switch? Which layout? TenKeyLess?
705 23222 331
New
AndyL
With this week’s release, ElixirLS bundles an experimental MCP Server. (see CHANGELOG) Highlights Added Call hierarchy provider imple...
New
xiaoqiang
These past few days, I’ve tried switching from Neovim to Helix, and so far the experience has been great. Compared to neovim, which requi...
New
AstonJ
Not sure I’m going to upgrade myself yet, but curious what others think: How are you finding it for dev? What are your thoughts of it g...
New
BartOtten
How do you all enter the pipe operator |> on your keyboard? I keep having troubles with it :frowning:
New
JoeZMar
After the keyboard thread has convinced me to purchase a UHK I wanted to make one about the mouse. Switching to a programmable keyboard h...
New
law
/an-aside Why is it not completing the module name too? Atom’s does. Also why does it not fill in the arguments with defaults that yo...
New
AstonJ
How fast is your internet connection? (And how much do you pay?) You can test via www.speedtest.net and to embed results into your post...
New
dimitarvp
Yeah, feels the same here. :confused: And I made a much bigger investment, the iMac Pro I got was $8000 at the time I bought it (2019). ...
New
sodapopcan
I get the impression that the Elixir community at large is using nvim, though it occurred to me that I don’t actually know this so I thou...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement