Thread overview
Error: variable `impl` cannot be modified at compile time
May 13, 2022
zoujiaqing
May 13, 2022
zoujiaqing
May 13, 2022
% git clone https://github.com/kerisy/archttp.git
% cd archttp/
% dub build --compiler=dmd
Performing "debug" build using dmd for x86_64.
archttp 0.0.1+commit.3.g70d44ef: building configuration "library"...
../../.dub/packages/nbuff-0.1.14/nbuff/source/nbuff/buffer.d(74,25): Deprecation: `catch` statement without an exception specification is deprecated
../../.dub/packages/nbuff-0.1.14/nbuff/source/nbuff/buffer.d(74,25):        use `catch(Throwable)` for old behavior
SSE: false
/opt/dmd/osx/bin/../../src/phobos/std/stdio.d(5190,5): Error: variable `impl` cannot be modified at compile time
/opt/dmd/osx/bin/../../src/phobos/std/stdio.d(4130,12):        called from here: `makeGlobal()`
/opt/dmd/osx/bin/../../src/phobos/std/stdio.d(4220,18):        called from here: `trustedStdout()`

Why can't we use writeln in constructors?
Comment out writeln so that the code will compile properly!

May 13, 2022

On 5/13/22 3:39 PM, zoujiaqing wrote:

>
% git clone https://github.com/kerisy/archttp.git
% cd archttp/
% dub build --compiler=dmd
Performing "debug" build using dmd for x86_64.
archttp 0.0.1+commit.3.g70d44ef: building configuration "library"...
../../.dub/packages/nbuff-0.1.14/nbuff/source/nbuff/buffer.d(74,25): Deprecation: `catch` statement without an exception specification is deprecated
../../.dub/packages/nbuff-0.1.14/nbuff/source/nbuff/buffer.d(74,25):        use `catch(Throwable)` for old behavior
SSE: false
/opt/dmd/osx/bin/../../src/phobos/std/stdio.d(5190,5): Error: variable `impl` cannot be modified at compile time
/opt/dmd/osx/bin/../../src/phobos/std/stdio.d(4130,12): called from here: `makeGlobal()`
/opt/dmd/osx/bin/../../src/phobos/std/stdio.d(4220,18): called from here: `trustedStdout()`

Why can't we use writeln in constructors?
Comment out writeln so that the code will compile properly!

What writeln? Your compile trace is missing the original call line, and I would say probably more.

From what you are saying, it appears that you are calling writeln inside a constructor, and you are attempting to build an instance of the object at compile time.

Instead of commenting out the writeln, maybe gate it with if(!__ctfe).

-Steve

May 13, 2022

On 5/13/22 3:46 PM, Steven Schveighoffer wrote:

>

What writeln? Your compile trace is missing the original call line, and I would say probably more.

Looking at your last commit, I figured it out:

https://github.com/kerisy/archttp/blob/545b3eb738261e92c88b4e4bb664b4fdfb206398/source/archttp/codec/HttpDecoder.d#L31

That's where you are attempting to build an HttpRequestParser at compile time.

Just use the __ctfe trick.

-Steve

May 13, 2022

On Friday, 13 May 2022 at 19:48:04 UTC, Steven Schveighoffer wrote:

>

On 5/13/22 3:46 PM, Steven Schveighoffer wrote:

>

What writeln? Your compile trace is missing the original call line, and I would say probably more.

Looking at your last commit, I figured it out:

https://github.com/kerisy/archttp/blob/545b3eb738261e92c88b4e4bb664b4fdfb206398/source/archttp/codec/HttpDecoder.d#L31

That's where you are attempting to build an HttpRequestParser at compile time.

Just use the __ctfe trick.

-Steve
Thank you my friend.