Skip to content

Unsafe.cast causes Compiler bug #347

Description

@Skyb0rg007

Version

110.99.7.1 (Latest)

Operating System

  • Any
  • Linux
  • macOS
  • Windows
  • Other Unix

OS Version

Ubuntu on WSL2

Processor

  • Any
  • Arm (using Rosetta)
  • PowerPC
  • Sparc
  • x86 (32-bit)
  • x86-64 (64-bit)
  • Other

System Component

Core system

Severity

Minor

Description

Using Unsafe.cast to implement polymorphic recursion cases the error Error: Compiler bug: Contract: UsageMap on v358 on current version of SML/NJ.
See gist here

Transcript

$  sml < val-rec-polyrec2.sml
Standard ML of New Jersey [Version 110.99.7.1; 64-bit; January 17, 2025]
- = [autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable]
[autoloading done]
Error: Compiler bug: Contract: UsageMap on v358
...

Expected Behavior

$ /usr/bin/sml < val-rec-polyrec2.sml
Standard ML of New Jersey v110.79 [built: Sat Oct 26 12:27:04 2019]
- = [autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable]
[autoloading done]
datatype 'a nested = Epsilon | Nest of 'a * 'a list nested
val sumListWith = fn : ('a -> int) -> 'a list -> int
val go = fn : ('a -> int) * 'a nested * int -> int
val sum = fn : int nested -> int
val nested = Nest (1,Nest ([#,#,#],Nest #)) : int nested
val nestedSum = 45 : int

Steps to Reproduce

See gist

Additional Information

No response

Email address

skyler DOT soss AT gmail DOT com

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompilerproblem with compilerfixed-in-110.99.8Issues fixed in the 110.99.8 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions