-
Notifications
You must be signed in to change notification settings - Fork 296
Conversation
There's actually a compatibility module that the OTP team published that might be interesting to adopt, although it does rely on Otherwise we might have to go the macro way like for typespecs. |
lists:flatten(io_lib:format("~4..0w~2..0w~2..0w_~2..0w~2..0w~2..0w", | ||
[Y, M, D, H, Min, S])). | ||
|
||
%% Even though we don't have -mode(compile), erl_lint:module/1 is run in | ||
%% escript, so we still have to silence the deprecation warning. | ||
-compile({nowarn_deprecated_function, [{erlang, now, 0}]}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using nowarn_deprecated_function
the functions should only be included if the functions are deprecated for all supported versions. Otherwise a warning is raised in releases where the function is not deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, but we'd have to add a wrapper around bootstrap or run bootstrap from bootstrap. Unless you know a simpler solution, I'm not sure it's worth the complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be used without naming the function:
-compile(nowarn_deprecated_function).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't use that because it's too broad and can hide warnings we want to see, but if the pre-18.x warning is a real concern, perhaps we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would just calling erlang:now()
get the linter to shut up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't but I think apply(erlang, now, [])
might.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would just calling erlang:now() get the linter to shut up?
No.
pre-18.0 warning due to nowarn_deprecated_function:
./bootstrap:127: Warning: erlang:now/0 is not a deprecated function
18.0 warning due to missing nowarn_deprecated_function:
./bootstrap:141: Warning: erlang:now/0: Deprecated BIF.[...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't but I think apply(erlang, now, []) might.
Thanks James, apply/3 works. See #478.
No description provided.