Home My Page Projects Code Snippets Project Openings SML/NJ Bugs
Summary Activity Tracker Lists

[#60] Incorrect type inference with functor taking/producing polymorphic type

Date:
2010-11-19 21:30
Priority:
3
State:
Closed
Submitted by:
Bug Submitter (webuser)
Assigned to:
David MacQueen (dbm)
Machine Architecture:
None
Operating System:
Generic Unix
Component:
Compiler
Resolution:
Fixed
Severity:
Major
OS Version:
SML/NJ Version:
110.72
Keywords:
types
URL:
Transcript (of reproduction):
- use ug.ml; [opening bug.ml] bug.ml:16.4-16.33 Error: operator and operand don agree [literal] operator domain: int Bad.bad_poly * int operand: int Bad.bad_poly * string in expression: Data (bd,\) uncaught exception Error raised at: ../compiler/TopLevel/interact/evalloop.sml:66.19-66.27 ../compiler/TopLevel/interact/evalloop.sml:44.55 ../compiler/TopLevel/interact/evalloop.sml:296.17-296.20
Source (for reproduction):
functor MkBad (type 'a bad_poly) = struct type a bad_poly = 'a bad_poly end structure Bad = MkBad (type 'a bad_poly = unit) datatype 'a bad_data = Data of a Bad.bad_poly * 'a fun demo bd = (Data (bd, 1), Data (bd, true))
Summary:
Incorrect type inference with functor taking/producing polymorphic type

Detailed description
In the problem code, SMLNJ fails to infer the correct type of the `demo function.

When a type annotation is added to the function then the code compiles:


fun demo bd =
(Data (bd, 1), Data (bd:string Bad.bad_poly, \))
Additional comments:
This bug appeared in SMLNJ 110.63.1 - 110.63 does not have the problem.

It was found in the wild in AliceML (http://www.ps.uni-saarland.de/pipermail/alice-users/2009/000977.html)

Submitted via web form by Gareth garethdanielsmith@gmail.com

Comments:

Message  ↓
Date: 2012-01-18 22:56
Sender: David MacQueen

DBM: Fixed by calling ElabUtil.calc_strictness on the body of a DEFtyc instantiated by a functor application in evalTyc in EvalEntityFct. (Elaborator/modules/evalent.sml).

Attached Files:

Changes

Field Old Value Date By
status_idOpen2012-01-18 22:56dbm
close_date2012-01-18 22:562012-01-18 22:56dbm
ResolutionNone2012-01-18 22:56dbm
assigned_tonone2011-03-22 13:34jhr