On Mon, Dec 30, 2019 at 06:18:49PM +0000, uranuz via Digitalmars-d-learn wrote:
[...]
>       void getCompiledTemplate(HTTPContext ctx)
>       {
>               import std.exception: enforce;
>               enforce(ctx, `ctx is null`);
>               enforce(ctx.request, `ctx.request is null`);
>               enforce(ctx.request.form, `ctx.request is null`);
>               enforce(ivyEngine !is null, `ivyEngine is null`);
>               string moduleName = ctx.request.form[`moduleName`];
>               auto mod = ivyEngine.getByModuleName(moduleName);
>               return ctx.response.write(mod.toStdJSON().toString());
>       }
> 
> 
> So as you see I have added a lot of enforce to test if all variables
> are not null. But nothing was null and the reason of segfault were
> unclear.  Today I just went home. Opened a bottle of beer. And have
> noticed that function is marked as returning `void`, but in fact it
> doesn't. When I fixed this segfault have gone. But why this even
> compiled?! Interesting...

That's weird indeed. Do you have a minimal case that reproduces this
problem? I tried to return the result of a non-void function call from a
void function, and it wouldn't compile, as expected.  It would be
interesting to see when exactly this compiler check is wrongly skipped.


T

-- 
Ignorance is bliss... until you suffer the consequences!

Reply via email to