Obfuscated code challenge

tsbockman thomas.bockman at gmail.com
Sun Mar 14 04:11:48 UTC 2021


On Sunday, 14 March 2021 at 01:31:36 UTC, Phillip Meyer wrote:
> See if you can figure out what this code does without running 
> it ;)

Nope. I couldn't make sense of the mixin. (Also, this only works 
because of a compiler bug that I didn't know about.)

> import std;void 
> main(){(*["clung/locks"].tee!(function(x){return 
> x;}).array.ptr).enumerate.map!(i=>mixin(cast(typeof({}))(6.8*13.3824)~"6r0d2a5 ".array.chunks(2).map!(i=>[i[0].to!string~":"~39~(i[1].to!string)~'\''][0]).join(",")~"]").get(i[0],i[1])).writeln;}

WAT?! Why is concatenating a function pointer with a char string 
not an error, even in @system code?

unittest {
     // This passes!
     assert(is(typeof(cast(typeof({})) 91) == void function() pure 
@safe nothrow @nogc));
     assert((cast(typeof({})) 91) ~ "" == "[");
}

I filed a DMD issue:
     https://issues.dlang.org/show_bug.cgi?id=21711



More information about the Digitalmars-d mailing list