diff --git a/src/dmd/hdrgen.d b/src/dmd/hdrgen.d index 680d9c82a965..723b7be68ca3 100644 --- a/src/dmd/hdrgen.d +++ b/src/dmd/hdrgen.d @@ -1890,7 +1890,17 @@ private void expressionPrettyPrint(Expression e, OutBuffer* buf, HdrGenState* hg buf.printf("%uu", cast(uint)v); break; case Tint64: - buf.printf("%lldL", v); + if (v == long.min) + { + // https://issues.dlang.org/show_bug.cgi?id=23173 + // This is a special case because - is not part of the + // integer literal and 9223372036854775808L overflows a long + buf.writestring("cast(long)-9223372036854775808"); + } + else + { + buf.printf("%lldL", v); + } break; case Tuns64: buf.printf("%lluLU", v); diff --git a/test/compilable/test23173.d b/test/compilable/test23173.d new file mode 100644 index 000000000000..6b16132d518f --- /dev/null +++ b/test/compilable/test23173.d @@ -0,0 +1,6 @@ +// REQUIRED_ARGS: -o- +// https://issues.dlang.org/show_bug.cgi?id=23173 + +mixin("long l = ", long.min, ";"); +static assert(mixin(long.min) == long.min); +static assert(is(typeof(mixin(long.min)) == long));