debug=BUG; void foo() { debug(BUG) import anything; } --- Import::semantic is assuming that the scope has a scope symbol and calls importScope on it. It segfaults because debug create a new scope without symbol. The correct fix seems to be calling importScope on the first enclosing scope that has a symbol. That way it behaves as Scope::insert(Dsymbol*).
https://github.com/D-Programming-Language/dmd/pull/333
https://github.com/D-Programming-Language/dmd/commit/8fa4a9e57e7f291848a3f69317a90a989993605b