Skip to content

Segmentation fault on non-exhaustive pattern-matching in let rec #12032

@lupjo

Description

@lupjo

The following code causes a segmentation fault when compiled in bytecode (not in native):

let rec f =
	let [| f0 |] = [| 0 |] in
	function
	| 0 -> f0
	| n -> f (n - 1)

let _ = f 1

Even weirder, the issue still stands when replacing the code by this:

let rec f =
	let 0 = 0 in
	function
	| 0 -> 0
	| n -> f (n - 1)

let _ = f 1

It seems the conjunction of a non-exhaustive pattern-matching and a let rec doesn't work very well. To be fair, the manual only describes the case let rec f = let x = _ in _, and not the case where x is replaced by a pattern, but it seems that replacing it by any exhaustive non-constructor pattern (tuples, records, polymorphic variant, lazy) causes no such issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions