Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
af50df4
Rename grammar entities for more descriptive names
Bolpat Nov 4, 2020
a4957d7
Implement BasicType as primary type (expression)
Bolpat May 17, 2023
9a456ed
Fix issue 2753 - add good case tests
May 17, 2023
3d655e8
Finished implementation
May 23, 2023
6cb72d3
Fix demo
May 23, 2023
790c08c
Adapt test cases to new pretty print syntax + additional errors
May 23, 2023
8af393a
Allow (type).ident for type 'ref T function()'
May 23, 2023
7ee75bf
Merge branch 'master' of https://github.com/Bolpat/dmd
Oct 20, 2023
7e3ac97
Merge branch 'master' into PrimaryTypeSyntax
Oct 20, 2023
a279f3c
fix fail compilation
Oct 20, 2023
ca8d4ab
Merge branch 'dlang:master' into master
Bolpat Dec 15, 2023
e9adea8
Merge master
Dec 15, 2023
ac048a0
Better error message
Dec 20, 2023
dab04e4
Generalize string representation of types that require parentheses
Dec 20, 2023
ef7a14e
Parse linkage as part of function pointer and delegate types
Dec 20, 2023
2811bcb
Merge branch 'dlang:master' into PrimaryTypeSyntax
Bolpat Apr 25, 2024
eadcef3
Require exactly one callable suffix after linakge or
Jun 17, 2024
cfce118
Merge branch 'master' of https://github.com/Bolpat/dmd
Jun 17, 2024
d86eccf
Merge branch 'master' into PrimaryTypeSyntax
Jun 17, 2024
b73df13
Add support for parsing linkage on function literals
Jun 24, 2024
f40e9b1
Handle and diagnose ambiguous `ref` target for nested function ptr/de…
Jun 24, 2024
260adc4
Merge branch 'master' of https://github.com/Bolpat/dmd
Jul 24, 2024
ff916bc
Merge branch 'master' into PrimaryTypeSyntax
Jul 24, 2024
81b311e
Address `ref` variables being merged
Jul 25, 2024
d5a3893
Merge branch 'master' of https://github.com/Bolpat/dmd
Jul 31, 2024
2876778
Merge branch 'master' of https://github.com/Bolpat/dmd
Aug 7, 2024
afa9d02
Merge branch 'master' into PrimaryTypeSyntax
Aug 7, 2024
b891f1e
Merge branch 'master' of https://github.com/Bolpat/dmd
Aug 20, 2024
c8d048f
Merge branch 'master' into PrimaryTypeSyntax
Aug 20, 2024
5df15c3
Semantically apply linkage to types
Sep 19, 2024
995d70a
Fix build error on AutoTest etc.
Sep 19, 2024
fcfe35d
Remove trailing whitespace
Sep 21, 2024
2ff4191
Implement linkage for lambdas
Sep 21, 2024
c50fd39
Implement linkage for alias to template lambda
Sep 21, 2024
48077f9
Make linkage for non-alias template lambdas an error
Sep 21, 2024
d93ed13
Fix some parsing issues with lambdas and `scope`, improve error messages
Sep 24, 2024
8f968e5
Implement the Scope Guard Compromise
Bolpat Dec 23, 2024
c04eeda
Merge branch 'master' into PrimaryTypeSyntax
Bolpat Dec 23, 2024
6e4a1db
Merge branch 'master' into PrimaryTypeSyntax
Bolpat Jan 16, 2025
3418a1e
whitespace
Bolpat Jan 16, 2025
8a2b136
Older compiler issues
Bolpat Jan 16, 2025
d9d31e9
Merge branch 'master' into PrimaryTypeSyntax
Bolpat Jan 23, 2025
230ec0b
Merge branch 'master' into PrimaryTypeSyntax
Bolpat Jul 7, 2025
ac53497
Add compilable example
Bolpat Jul 7, 2025
9796a00
Fix problem with scope plus empty parens
Bolpat Jul 7, 2025
c9fe5c5
Merge branch 'master' into PrimaryTypeSyntax
Bolpat Jul 24, 2025
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.112.0-beta.1
v2.112.0-beta.1+PrimaryTypeSyntax
2 changes: 1 addition & 1 deletion compiler/src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor

if ((dsym.storage_class & (STC.ref_ | STC.field)) == (STC.ref_ | STC.field) && dsym.ident != Id.This)
{
.error(dsym.loc, "%s `%s` - field declarations cannot be `ref`", dsym.kind, dsym.toPrettyChars);
.error(dsym.loc, "%s `%s` - field declarations cannot be `ref`; use parentheses for a function pointer or delegate type with `ref` return", dsym.kind, dsym.toPrettyChars);
}

if (dsym.type.hasWild())
Expand Down
45 changes: 41 additions & 4 deletions compiler/src/dmd/hdrgen.d
Original file line number Diff line number Diff line change
Expand Up @@ -4016,21 +4016,56 @@ private void visitFuncIdentWithPostfix(TypeFunction t, const char[] ident, ref O
return;
}
t.inuse++;
bool parenWritten = false;
void openParenthesis()
{
if (!parenWritten)
{
buf.put('(');
parenWritten = true;
}
}
if (t.linkage > LINK.d && hgs.ddoc != 1 && !hgs.hdrgen)
{
openParenthesis();
linkageToBuffer(buf, t.linkage);
buf.put(' ');
}
if (t.linkage == LINK.objc && isStatic)
buf.write("static ");
buf.put("static ");
if (t.next)
{
if (t.isRef)
{
openParenthesis();
buf.put("ref ");
}
immutable bool hasNestedNonParendCallable = {
for ({ Type tt = t; TypeNext tn = null; } (tn = tt.isTypeNext) !is null;)
{
tt = tn.next;
switch (tt.ty)
{
case Tsarray, Tarray, Taarray, Tpointer, Treference, Tdelegate, Tslice: continue;
case Tfunction:
TypeFunction tf = cast(TypeFunction) tt;
return !tf.isRef && tf.linkage <= LINK.d;
default: return false;
}
}
return false;
}();
if (hasNestedNonParendCallable) buf.writeByte('(');
typeToBuffer(t.next, null, buf, hgs);
if (hasNestedNonParendCallable) buf.writeByte(')');
if (ident)
buf.put(' ');
}
else if (hgs.ddoc)
{
openParenthesis();
buf.put("auto ");
}
if (ident)
buf.put(ident);
parametersToBuffer(t.parameterList, buf, hgs);
Expand All @@ -4042,13 +4077,15 @@ private void visitFuncIdentWithPostfix(TypeFunction t, const char[] ident, ref O
MODtoBuffer(buf, t.mod);
}

void dg(string str)
void writeAttribute(string str)
{
if (str == "ref") return; // 'ref' is handled above
buf.put(' ');
buf.put(str);
}
t.attributesApply(&dg);

t.attributesApply(&writeAttribute);
if (parenWritten)
buf.put(')');
t.inuse--;
}

Expand Down
9 changes: 9 additions & 0 deletions compiler/src/dmd/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,15 @@ class Lexer
return peek(t).value;
}

/***********************
* Look 3 tokens ahead at value.
*/
final TOK peekNext3()
{
Token* t = peek(peek(&token));
return peek(t).value;
}

/****************************
* Turn next token in buffer into a token.
* Params:
Expand Down
26 changes: 26 additions & 0 deletions compiler/src/dmd/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,28 @@ extern (C++) abstract class Type : ASTNode
inout(TypeNoreturn) isTypeNoreturn() { return ty == Tnoreturn ? cast(typeof(return))this : null; }
inout(TypeTag) isTypeTag() { return ty == Ttag ? cast(typeof(return))this : null; }

inout(TypeArray) isTypeArray()
{
switch (ty)
{
case Tsarray, Tarray, Taarray:
return cast(typeof(return))this;
default:
return null;
}
}
inout(TypeNext) isTypeNext()
{
switch (ty)
{
case Tsarray, Tarray, Taarray:
case Tpointer, Treference, Tfunction, Tdelegate, Tslice:
return cast(typeof(return))this;
default:
return null;
}
}

extern (D) bool isStaticOrDynamicArray() const { return ty == Tarray || ty == Tsarray; }
}

Expand Down Expand Up @@ -1594,6 +1616,8 @@ extern (C++) abstract class TypeNext : Type
this.next = next;
}

abstract override TypeNext syntaxCopy();

override final int hasWild() const
{
if (ty == Tfunction)
Expand Down Expand Up @@ -2152,6 +2176,8 @@ extern (C++) abstract class TypeArray : TypeNext
super(ty, next);
}

abstract override TypeArray syntaxCopy();

override void accept(Visitor v)
{
v.visit(this);
Expand Down
Loading
Loading