Skip to content

Force increasing Range #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025

Conversation

alexandremcosta
Copy link
Contributor

@alexandremcosta alexandremcosta commented May 27, 2025

Keep the same behaviour as with earlier elixir versions.

Fix:

 warning: Range.new/2 and first..last default to a step of -1 when last < first. Use Range.new(first, last, -1) or first..last//-1, or pass 1 if that was your intention
  (mongodb_driver 1.5.2) lib/mongo/id_server.ex:43: Mongo.IdServer.handle_info/2
  (stdlib 6.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
  (stdlib 6.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
  (stdlib 6.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

Issue #271

Be aware I wasn't able to run tests locally. I have MongoDB running locally, but the test suite doesn't connect to it, and I can't find instructions on how to do that.

@zookzook
Copy link
Owner

zookzook commented Jun 3, 2025

I'm not sure if the solution solves the warning here, because you use a positive step value of 1. The warning is only printed if the step gets negative:

iex 1> Range.new(1,10)
1..10
iex 2> Range.new(10,1)
warning: Range.new/2 and first..last default to a step of -1 when last < first. Use Range.new(first, last, -1) or first..last//-1, or pass 1 if that was your intention
  (elixir 1.18.3) src/elixir.erl:386: :elixir.eval_external_handler/3
  (stdlib 6.2.2) erl_eval.erl:919: :erl_eval.do_apply/7
  (elixir 1.18.3) src/elixir.erl:364: :elixir.eval_forms/4
  (elixir 1.18.3) lib/module/parallel_checker.ex:120: Module.ParallelChecker.verify/1
  (iex 1.18.3) lib/iex/evaluator.ex:336: IEx.Evaluator.eval_and_inspect/3
  (iex 1.18.3) lib/iex/evaluator.ex:310: IEx.Evaluator.eval_and_inspect_parsed/3
  (iex 1.18.3) lib/iex/evaluator.ex:299: IEx.Evaluator.parse_eval_inspect/4
  (iex 1.18.3) lib/iex/evaluator.ex:189: IEx.Evaluator.loop/1
  (iex 1.18.3) lib/iex/evaluator.ex:34: IEx.Evaluator.init/5
  (stdlib 6.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

I assume the step value can be positive and negative.

@zookzook
Copy link
Owner

zookzook commented Jun 7, 2025

Thank you. I will change your code a bit to support different step values.

@zookzook zookzook merged commit 874098e into zookzook:master Jun 7, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants