Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Adapt to 18.x time api changes #475

Merged
merged 1 commit into from Apr 10, 2015
Merged

Adapt to 18.x time api changes #475

merged 1 commit into from Apr 10, 2015

Conversation

ghost
Copy link

@ghost ghost commented Apr 8, 2015

No description provided.

@ferd
Copy link
Contributor

ferd commented Apr 8, 2015

There's actually a compatibility module that the OTP team published that might be interesting to adopt, although it does rely on try...catch to work and would be subject to similar warnings.

Otherwise we might have to go the macro way like for typespecs.

ferd added a commit that referenced this pull request Apr 10, 2015
Adapt to 18.x time api changes
@ferd ferd merged commit 04d2634 into rebar:master Apr 10, 2015
@ghost ghost deleted the otp-18-time branch April 10, 2015 21:04
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}]}).
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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).

Copy link
Author

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.

@ferd?

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Author

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.[...]

Copy link
Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants