diff --git a/src/interpret.c b/src/interpret.c index dd8830a20ab7..b06399f73b22 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -5965,13 +5965,10 @@ class Interpreter : public Visitor StructLiteralExp *se = (StructLiteralExp *)ex; dinteger_t offset = ae->e2->toInteger(); result = se->getField(e->type, (unsigned)offset); - if (!result) - result = CTFEExp::cantexp; - return; + if (result) + return; } } - result = Ptr(e->type, e->e1).copy(); - return; } // Check for .classinfo, which is lowered in the semantic pass into **(class). diff --git a/test/fail_compilation/ice13835.d b/test/fail_compilation/ice13835.d new file mode 100644 index 000000000000..d07d7add4597 --- /dev/null +++ b/test/fail_compilation/ice13835.d @@ -0,0 +1,22 @@ +/* +TEST_OUPUT: +--- +fail_compilation/ice13835.d(15): Error: value of 'this' is not known at compile time +fail_compilation/ice13835.d(21): Error: template instance ice13835.Foo!int error instantiating +--- +*/ + +class Foo(T) +{ + private T* _data; + + final private void siftUp(int position) nothrow + { + static T crash = *(this._data + position); + } +} + +void main() +{ + auto heap = new Foo!(int); +}