New Issue: Error trying to read map from file

20004, "benharsh", "Error trying to read map from file", "2022-06-14T23:23:41Z"

Summary of Problem

I was updating the reading and writing implementation of various things, and observed this error while trying to confirm something unrelated. In the sample test below we print a map to a file and try to read it back in, but encounter a formatting error involving the ending curly-brace.

Steps to Reproduce

Source Code:


use IO;
use Map;

proc main() {
  var f = openmem();

  var m = new map(int, real);
  for i in 1..10 do m[i] = (i**2):real;

  var w = f.writer();
  w.write(m);

  {
    var r = f.reader();
    var contents : string;
    r.readstring(contents);
    writeln("Wrote:");
    writeln("==========");
    writeln(contents);
    writeln("==========");
  }

  var r = f.reader();
  var x : map(int,real);
  try {
    r.read(x);
    writeln(x);
  } catch (e : Error) {
    writeln("Error reading map:");
    writeln(e.message());
  }

}

This program fails with the following message when attempting to read the map back in:

bad format: missing expected literal (while reading ioLiteral "}" with path "unknown" offset 1)

Associated Future Test(s):
test/library/standard/Map/testMapIO.chpl #19983