Tighten stdlib typespecs to match implementations#15561
Merged
Conversation
josevalim
reviewed
Jul 9, 2026
| """ | ||
| @doc since: "1.16.0" | ||
| @spec levels() :: [level(), ...] | ||
| @spec levels() :: [:logger.level(), ...] |
Member
There was a problem hiding this comment.
Is this because of :warn? If so, we should update @type level to no longer include :warn!
Candidates found by cross-checking @specs against the type signatures inferred by the compiler (see elixir-lang#15559): these specs declared strictly wider return types than the functions can produce, where the gap carries no intentional API room (deliberately abstract contracts, such as atom() covering future values, are left untouched): * File.Stream.t/0: type the struct fields (mirrors IO.Stream.t/0) * Map.new/0: %{} instead of map() * Logger.levels/0: :logger.level() excludes :warn, which is only an accepted input alias and is never returned * Macro.Env.location/1 and Macro.Env.stacktrace/1: precise shapes Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6124608 to
0a2d892
Compare
Member
|
💚 💙 💜 💛 ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #15559 as requested. These specs declared strictly wider return types than the functions can produce, where the gap carries no intentional API room. Specs that are deliberately abstract (e.g.
atom()covering future values) were left untouched per the review feedback there.File.Stream.t/0: type the struct fields (mirrorsIO.Stream.t/0)Map.new/0:%{}instead ofmap()Logger.levels/0::logger.level()excludes:warn, which is only an accepted input alias and is never returnedMacro.Env.location/1andMacro.Env.stacktrace/1: precise shapes derived from the module's own field typesAssisted-By: Claude Fable 5
🤖 Generated with Claude Code