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

[#256] Ref.exchange incorrect

Date:
2020-04-24 04:07
Priority:
3
State:
Closed
Submitted by:
Bug Submitter (webuser)
Assigned to:
John Reppy (jhr)
Machine Architecture:
None
Operating System:
Generic Unix
Component:
Basis Library
Resolution:
Fixed
Severity:
Minor
OS Version:
SML/NJ Version:
v110.81, v110.96
Keywords:
ref
URL:
Transcript (of reproduction):
- val r = ref 1; val r = ref 1 : int ref - val (a,b) = (Ref.exchange (r,2), !r); val a = 2 : int val b = 1 : int
Source (for reproduction):
val r = ref 1 val (a,b) = (Ref.exchange (r,2), !r)
Summary:
Ref.exchange incorrect

Detailed description
Ref.exchange seems to have a minor typo in its implementation. It says:

fun exchange (r as ref x, y) = (r := x; y)

However, this doesn't seem to be the intended behavior, which would be:

fun exchange (r as ref x, y) = (r := y; x)
Fix:
fun exchange (r as ref x, y) = (r := y; x)

Submitted via web form by Harrison Grodin <hgrodin@andrew.cmu.edu>

Comments:

Message  ↓
Date: 2020-04-24 16:05
Sender: John Reppy

Fixed for 110.98. The original source of the bug was the Basis Library sample code, which has also been fixed.

Attached Files:

Changes

Field Old Value Date By
status_idOpen2020-04-24 16:05jhr
close_dateNone2020-04-24 16:05jhr
assigned_tonone2020-04-24 16:05jhr
summaryRef.exchange incorrect?2020-04-24 16:05jhr
detailsRef.exchange seems to have a minor typo in its implementation. It says: fun exchange (r as ref x, y) = (r := x; y) However, this doesn't seem to be the intended behavior, which would be: fun exchange (r as ref x, y) = (r := y; x) Fix: fun exchange (r as ref x, y) = (r := y; x) Submitted via web form by Harrison Grodin <hgrodin@andrew.cmu.edu> 2020-04-24 16:05jhr
ResolutionNone2020-04-24 16:05jhr
Transcript (of reproduction)- val r = ref 1; val r = ref 1 : int ref - val (a,b) = (Ref.exchange (r,2), !r); val a = 2 : int val b = 1 : int2020-04-24 16:05jhr
Source (for reproduction)val r = ref 1 val (a,b) = (Ref.exchange (r,2), !r)2020-04-24 16:05jhr