Skip to content

Array comparisons always result in polyEqual warning #331

Description

@Skyb0rg007

Version

110.99.6.1 (Latest)

Operating System

  • Any
  • Linux
  • macOS
  • Windows
  • Other Unix

OS Version

No response

Processor

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

System Component

Core system

Severity

Cosmetic

Description

The polyEqual warning is meant to warn users that the compiler is falling back to a non-synthesized equality test.
However, this warning occurs on completely legitimate uses on the array type.

Transcript

- val arr : char array = Array.array (10, #"x");
- arr = arr;
stdIn:2.5 Warning: calling polyEqual
val it = true : bool

Expected Behavior

- val arr : char array = Array.array (10, #"x");
- arr = arr;
val it = true : bool

This should probably not produce a warning even if the type is polymorphic, just like how ref works.

- fun myArrEq (a1 : 'a array, a2 : 'a array) : bool = a1 = a2;
val it = fn : 'a array * 'a array -> bool

Steps to Reproduce

Write = on arrays.

Additional Information

This is probably fairly easy to special-case for now, but the polyEqual warning needs an overhaul.
The warning should really be based on the type of expressions (ie. the warning should occur before the backend), rather than the contents of the optimized intermediate language.
We should be able to guarantee that all well-understood uses of op = are specialized.

Email address

skyler DOT soss AT gmail DOT com

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions