www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Regression?

reply "Sebastiaan Koppe" <mail skoppe.eu> writes:
This used to work in older compiler (might have been v2.067 or 
v2.066, not older).

```
#!rdmd

import std.stdio;
import std.json;
import std.algorithm;

void main() {
	auto ls = 
File("../languages.json","r").byLineCopy().joiner.parseJSON();
}
```

Error: c:\D\dmd2\windows\bin\..\..\src\phobos\std\json.d(639): 
Error: variable std.json.parseJSON!(Result).parseJSON.json has 
scoped destruction, cannot build closure
Sep 06 2015
next sibling parent "Sebastiaan Koppe" <mail skoppe.eu> writes:
Dammit, i am on windows, DMD32 D Compiler v2.068.0
Sep 06 2015
prev sibling parent reply "Sebastiaan Koppe" <mail skoppe.eu> writes:
Fixed it by changing into:

```
	import std.conv : text;
	string json = 
File("../languages.json","r").byLineCopy().joiner.text;
	auto ls = json.parseJSON();
```
Sep 07 2015
parent reply "FreeSlave" <freeslave93 gmail.com> writes:
On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe 
wrote:
 Fixed it by changing into:

 ```
 	import std.conv : text;
 	string json = 
 File("../languages.json","r").byLineCopy().joiner.text;
 	auto ls = json.parseJSON();
 ```
Why would you read file by line and then merge all into one string? You end up with reading the whole file (well, getting rid of line ends) anyway, so probably the more efficient solution would be just read the whole file at once with std.file.read and cast to string.
Sep 08 2015
next sibling parent Jonathan M Davis via Digitalmars-d-learn writes:
On Tuesday, September 08, 2015 07:12:50 FreeSlave via Digitalmars-d-learn wrote:
 On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe
 wrote:
 Fixed it by changing into:

 ```
     import std.conv : text;
     string json =
 File("../languages.json","r").byLineCopy().joiner.text;
     auto ls = json.parseJSON();
 ```
Why would you read file by line and then merge all into one string? You end up with reading the whole file (well, getting rid of line ends) anyway, so probably the more efficient solution would be just read the whole file at once with std.file.read and cast to string.
Or just use std.file.readText: http://dlang.org/phobos/std_file.html#readText - Jonathan M Davis
Sep 08 2015
prev sibling parent reply "Sebastiaan Koppe" <mail skoppe.eu> writes:
On Tuesday, 8 September 2015 at 07:12:52 UTC, FreeSlave wrote:
 On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe 
 wrote:
 Fixed it by changing into:

 ```
 	import std.conv : text;
 	string json = 
 File("../languages.json","r").byLineCopy().joiner.text;
 	auto ls = json.parseJSON();
 ```
Why would you read file by line and then merge all into one string? You end up with reading the whole file (well, getting rid of line ends) anyway, so probably the more efficient solution would be just read the whole file at once with std.file.read and cast to string.
Thanks for your advice. But that is not what I asked for. The question was, why doesn't this work anymore with the latest (2.068.0 and 2.068.1) compiler: ``` auto ls = File("../languages.json","r").byLineCopy().joiner.parseJSON(); ``` It should. Right?
Sep 08 2015
next sibling parent Jack Stouffer <jack jackstouffer.com> writes:
On Wednesday, 9 September 2015 at 01:35:26 UTC, Sebastiaan Koppe 
wrote:
 Thanks for your advice. But that is not what I asked for.

 The question was, why doesn't this work anymore with the latest 
 (2.068.0 and 2.068.1) compiler:

 ```
 auto ls = 
 File("../languages.json","r").byLineCopy().joiner.parseJSON();
 ```

 It should. Right?
I just ran into this as well. This seems like a regression.
Dec 08 2015
prev sibling parent Jack Stouffer <jack jackstouffer.com> writes:
On Wednesday, 9 September 2015 at 01:35:26 UTC, Sebastiaan Koppe 
wrote:
 Thanks for your advice. But that is not what I asked for.

 The question was, why doesn't this work anymore with the latest 
 (2.068.0 and 2.068.1) compiler:

 ```
 auto ls = 
 File("../languages.json","r").byLineCopy().joiner.parseJSON();
 ```

 It should. Right?
https://issues.dlang.org/show_bug.cgi?id=15423
Dec 08 2015