Skip to content
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

"index out of bounds" when compiling pattern matching on long sum type #6674

Closed
vicuna opened this Issue Nov 25, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Nov 25, 2014

Original bug ID: 6674
Reporter: @alainfrisch
Assigned to: @maranget
Status: closed (set by @xavierleroy on 2016-12-07T10:37:00Z)
Resolution: fixed
Priority: high
Severity: crash
Fixed in version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)
Related to: #6646

Bug description

On trunk, but not on 4.02, I get the following exception:

Fatal error: exception Invalid_argument("index out of bounds")

when compiling (with ocamlc) the code below:

type t =
  | A1
  | A2
  | A3
  | A4
  | A5
  | A6
  | A7
  | A8
  | A9
  | A10
  | A11
  | A12
  | A13
  | A14
  | A15
  | A16
  | A17
  | A18
  | A19
  | A20
  | A21
  | A22
  | A23
  | A24
  | A25
  | A26
  | A27
  | A28
  | A29
  | A30
  | A31
  | A32
  | X of string

let f = function
  | X _ -> true
  | _ -> false

Here is the top of the stacktrace:

Raised by primitive operation at file "bytecomp/switch.ml", line 746, characters 2-22
Called from file "bytecomp/switch.ml", line 840, characters 21-36
Called from file "bytecomp/switch.ml", line 862, characters 5-35
Called from file "bytecomp/matching.ml", line 2469, characters 21-108
Called from file "bytecomp/matching.ml", line 2743, characters 28-64
Re-raised at file "bytecomp/matching.ml", line 2717, characters 10-46
Called from file "bytecomp/matching.ml", line 2793, characters 6-145
Called from file "bytecomp/matching.ml", line 2977, characters 30-73
Called from file "bytecomp/translcore.ml", line 1090, characters 7-88
...
@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 25, 2014

Comment author: @alainfrisch

Most certainly related to revision 15570.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 25, 2014

Comment author: @alainfrisch

Probably not the intended fix, but removing the test "List.length fail_pats < 32" in matching.ml (always going to the "true" branch) removes the problem.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 25, 2014

Comment author: @maranget

Fixed in the trunk, thanks.

--Luc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.