Skip to content

Raise Invalid_arg if Hashtbl.create is given a negative init size - #13474

Closed
MisterDA wants to merge 1 commit into
ocaml:trunkfrom
MisterDA:hashtbl-create-forbid-negative-size
Closed

Raise Invalid_arg if Hashtbl.create is given a negative init size#13474
MisterDA wants to merge 1 commit into
ocaml:trunkfrom
MisterDA:hashtbl-create-forbid-negative-size

Conversation

@MisterDA

Copy link
Copy Markdown
Contributor

Fix #13469. This is akin to e.g., List.init.

@MisterDA
MisterDA force-pushed the hashtbl-create-forbid-negative-size branch 2 times, most recently from 6d0d20d to bf7b44c Compare September 24, 2024 16:39
@MisterDA
MisterDA force-pushed the hashtbl-create-forbid-negative-size branch from bf7b44c to 7b0be0e Compare September 25, 2024 00:06
@MisterDA

Copy link
Copy Markdown
Contributor Author

cc @nikolaushuber @jmid

@jmid

jmid commented Sep 27, 2024

Copy link
Copy Markdown
Member

The fix LGTM 👍

Strictly speaking this is a backward-incompatible change.
We might want to discuss the issue before moving to a fix.

  • It is indeed minor, so it might just fall under "won't fix" but "reasonable to document as an issue"
  • If we move forward with the PR, we should be sure not to break too much code

Finally, as a Stdlib change this will require 2 core dev approvals.

@Octachron

Copy link
Copy Markdown
Member

I like the fix in principle. Nevertheless, I worry that this fix can break perfectly working code whereas I struggle to imagine a situation where this fix would help identify a meaningful bug.

@avsm

avsm commented Sep 27, 2024

Copy link
Copy Markdown
Member

This seems like a regression to me; it'll potentially raise exceptions in currently working code, but add no real improvements. Wouldn't it be better to document the minimum and maximum values, and add a note that values outside this range will be clamped to those?

@gasche

gasche commented Oct 2, 2024

Copy link
Copy Markdown
Member

We discussed this at our triaging meeting today, and we couldn't really find overwhelming support in favor of the PR -- we agree that programs should not do this, but we don't necessarily agree that breaking them is the right reaction. (Of course if this was like this from scratch it would be fine.)

@OlivierNicole

Copy link
Copy Markdown
Contributor

The majority opinion among maintainers is that the behaviour should not be changed, but the documentation should be.

NickBarnes added a commit to NickBarnes/ocaml that referenced this pull request Oct 2, 2024
…iage discussion of ocaml#13474 concluded that we should allow negative values but document that they are disregarded.
@MisterDA MisterDA closed this Oct 2, 2024
@MisterDA
MisterDA deleted the hashtbl-create-forbid-negative-size branch October 2, 2024 14:05
MisterDA pushed a commit to MisterDA/ocaml that referenced this pull request Oct 9, 2024
Majority view in the triage discussion of ocaml#13474 concluded that we
should allow negative values but document that they are disregarded.
MisterDA pushed a commit to MisterDA/ocaml that referenced this pull request Oct 9, 2024
Majority view in the triage discussion of ocaml#13474 concluded that we
should allow negative values but document that they are disregarded.
MisterDA pushed a commit to MisterDA/ocaml that referenced this pull request Oct 16, 2024
Majority view in the triage discussion of ocaml#13474 concluded that we
should allow negative values but document that they are disregarded.
MisterDA pushed a commit to MisterDA/ocaml that referenced this pull request Oct 18, 2024
Majority view in the triage discussion of ocaml#13474 concluded that we
should allow negative values but document that they are disregarded.
MisterDA pushed a commit to MisterDA/ocaml that referenced this pull request Oct 18, 2024
Majority view in the triage discussion of ocaml#13474 concluded that we
should allow negative values but document that they are disregarded.
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.

Hashtbl.create with negative initial guess

6 participants