Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mixin with interpolated strings #20629

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4294,9 +4294,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
// we need to turn that into:
/+
tuple(
.object.imported!"core.interpolation".InterpolationHeader(),
InterpolationHeader(),
...
.object.imported!"core.interpolation".InterpolationFooter()
InterpolationFooter()
)

There the ... loops through them all, making the even ones
Expand All @@ -4312,12 +4312,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
error(e.loc, "String postfixes on interpolated expression sequences are not allowed.");

Expression makeNonTemplateItem(Identifier which) {
Expression id = new IdentifierExp(e.loc, Id.empty);
id = new DotIdExp(e.loc, id, Id.object);
auto moduleNameArgs = new Objects();
moduleNameArgs.push(new StringExp(e.loc, "core.interpolation"));
id = new DotTemplateInstanceExp(e.loc, id, Id.imported, moduleNameArgs);
id = new DotIdExp(e.loc, id, which);
Expression id = new IdentifierExp(e.loc, which);
id = new CallExp(e.loc, id, new Expressions());
return id;
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/test/fail_compilation/imphint.d
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ fail_compilation/imphint.d(102): Error: `startsWith` is not defined, perhaps `im
fail_compilation/imphint.d(103): Error: `take` is not defined, perhaps `import std.range;` is needed?
fail_compilation/imphint.d(104): Error: `text` is not defined, perhaps `import std.conv;` is needed?
fail_compilation/imphint.d(105): Error: `to` is not defined, perhaps `import std.conv;` is needed?
fail_compilation/imphint.d(107): Error: `InterpolationHeader` is not defined, perhaps `import core.interpolation;` ?
fail_compilation/imphint.d(108): Error: template `heresy` is not callable using argument types `!()(InterpolationHeader, InterpolationFooter)`
fail_compilation/imphint.d(107): Candidate is: `heresy(Args...)(InterpolationHeader header, Args args, InterpolationFooter footer)`
---
*/








void foo()
{
printf("hello world\n");
Expand Down
5 changes: 5 additions & 0 deletions druntime/src/object.d
Original file line number Diff line number Diff line change
Expand Up @@ -4721,6 +4721,11 @@ public import core.lifetime : _d_newclassT;
public import core.lifetime : _d_newclassTTrace;
public import core.lifetime : _d_newitemT;

public import core.interpolation : InterpolationHeader;
public import core.interpolation : InterpolationFooter;
public import core.interpolation : InterpolatedLiteral;
public import core.interpolation : InterpolatedExpression;

public @trusted @nogc nothrow pure extern (C) void _d_delThrowable(scope Throwable);

// Compare class and interface objects for ordering.
Expand Down
Loading