Issue 24410 - Assertion for syntax error with interpolation string
Summary: Assertion for syntax error with interpolation string
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-25 11:52 UTC by Tim
Modified: 2024-05-08 15:05 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Tim 2024-02-25 11:52:26 UTC
The following code is wrong, because it is missing a closing paren:
```
void main()
{
    writeln(simpleToString(i"$(b)");
}
```
After the error message it also triggers an assertion for DMD (current master) in src/dmd/hdrgen.d:

testinterp.d(3): Error: found `;` when expecting `)`
testinterp.d(4): Error: found `}` when expecting `;` following expression
---
ERROR: This is a compiler bug.
Please report it via https://issues.dlang.org/enter_bug.cgi
with, preferably, a reduced, reproducible example and the information below.
DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.
---
DMD v2.107.1-rc.1-240-g17293af33a
predefs   DigitalMars LittleEndian D_Version2 all D_SIMD Posix ELFv1 linux CRuntime_Glibc CppRuntime_Gcc D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_PreConditions D_PostConditions D_Invariants D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary    /home/tim/Programmieren/dlang/dmd/generated/linux/release/64/dmd
version   v2.107.1-rc.1-240-g17293af33a
config    /home/tim/Programmieren/dlang/dmd/generated/linux/release/64/dmd.conf
DFLAGS    -I/home/tim/Programmieren/dlang/dmd/generated/linux/release/64/../../../../druntime/import -I/home/tim/Programmieren/dlang/dmd/generated/linux/release/64/../../../../../phobos -L-L/home/tim/Programmieren/dlang/dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64 -L--export-dynamic -fPIC
---
core.exception.AssertError@src/dmd/hdrgen.d(3669): Assertion failure
----------------
??:? _d_assertp [0x6214b7b44420]
src/dmd/hdrgen.d:3669 void dmd.hdrgen.expToBuffer(dmd.expression.Expression, dmd.parse.PREC, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState) [0x6214b7924174]
src/dmd/hdrgen.d:3591 void dmd.hdrgen.argsToBuffer(dmd.root.array.Array!(dmd.expression.Expression).Array*, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState, dmd.expression.Expression, dmd.root.array.Array!(dmd.identifier.Identifier).Array*) [0x6214b7923f9d]
src/dmd/hdrgen.d:2743 void dmd.hdrgen.expressionPrettyPrint(dmd.expression.Expression, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState).visitCall(dmd.expression.CallExp) [0x6214b7921a54]
src/dmd/hdrgen.d:2945 void dmd.hdrgen.expressionPrettyPrint(dmd.expression.Expression, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState) [0x6214b791f315]
src/dmd/hdrgen.d:3650 void dmd.hdrgen.expressionToBuffer(dmd.expression.Expression, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState) [0x6214b79240d8]
src/dmd/hdrgen.d:3683 void dmd.hdrgen.expToBuffer(dmd.expression.Expression, dmd.parse.PREC, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState) [0x6214b792429f]
src/dmd/hdrgen.d:3591 void dmd.hdrgen.argsToBuffer(dmd.root.array.Array!(dmd.expression.Expression).Array*, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState, dmd.expression.Expression, dmd.root.array.Array!(dmd.identifier.Identifier).Array*) [0x6214b7923f9d]
src/dmd/hdrgen.d:2743 void dmd.hdrgen.expressionPrettyPrint(dmd.expression.Expression, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState).visitCall(dmd.expression.CallExp) [0x6214b7921a54]
src/dmd/hdrgen.d:2945 void dmd.hdrgen.expressionPrettyPrint(dmd.expression.Expression, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState) [0x6214b791f315]
src/dmd/hdrgen.d:3383 void dmd.hdrgen.toCBuffer(const(dmd.expression.Expression), ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState) [0x6214b79235e0]
src/dmd/hdrgen.d:119 const(char)* dmd.hdrgen.toChars(const(dmd.expression.Expression)) [0x6214b7916f5a]
src/dmd/expression.d:392 _ZNK10Expression7toCharsEv [0x6214b78c6eec]
src/dmd/parse.d:5884 dmd.statement.Statement dmd.parse.Parser!(dmd.astcodegen.ASTCodegen, dmd.lexer.Lexer).Parser.parseStatement(int, const(char)**, dmd.location.Loc*) [0x6214b7970431]
src/dmd/parse.d:6079 dmd.statement.Statement dmd.parse.Parser!(dmd.astcodegen.ASTCodegen, dmd.lexer.Lexer).Parser.parseStatement(int, const(char)**, dmd.location.Loc*) [0x6214b7970bbc]
src/dmd/parse.d:5233 dmd.func.FuncDeclaration dmd.parse.Parser!(dmd.astcodegen.ASTCodegen, dmd.lexer.Lexer).Parser.parseContracts(dmd.func.FuncDeclaration, bool) [0x6214b796f4cf]
src/dmd/parse.d:4612 dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array* dmd.parse.Parser!(dmd.astcodegen.ASTCodegen, dmd.lexer.Lexer).Parser.parseDeclarations(bool, dmd.parse.PrefixAttributes!(dmd.astcodegen.ASTCodegen).PrefixAttributes*, const(char)*) [0x6214b796d399]
src/dmd/parse.d:426 dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array* dmd.parse.Parser!(dmd.astcodegen.ASTCodegen, dmd.lexer.Lexer).Parser.parseDeclDefs(int, dmd.dsymbol.Dsymbol*, dmd.parse.PrefixAttributes!(dmd.astcodegen.ASTCodegen).PrefixAttributes*) [0x6214b7963f39]
src/dmd/parse.d:161 dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array* dmd.parse.Parser!(dmd.astcodegen.ASTCodegen, dmd.lexer.Lexer).Parser.parseModuleContent() [0x6214b796389a]
src/dmd/dmodule.d:807 dmd.dmodule.Module dmd.dmodule.Module.parseModule!(dmd.astcodegen.ASTCodegen).parseModule() [0x6214b7871d34]
src/dmd/dmodule.d:717 _ZN6Module5parseEv [0x6214b786fdb0]
src/dmd/main.d:378 int dmd.main.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0x6214b77ffd23]
src/dmd/main.d:134 _Dmain [0x6214b77ff65c]
Comment 1 Nick Treleaven 2024-05-08 15:05:08 UTC
Works with v2.108.1