Fix bug with auto variable declarations
This commit is contained in:
parent
63cbef8864
commit
81e652c4c8
|
@ -547,18 +547,18 @@ static this()
|
||||||
STRING_LITERAL_SYMBOL_NAME = internString("*string");
|
STRING_LITERAL_SYMBOL_NAME = internString("*string");
|
||||||
WSTRING_LITERAL_SYMBOL_NAME = internString("*wstring");
|
WSTRING_LITERAL_SYMBOL_NAME = internString("*wstring");
|
||||||
|
|
||||||
auto bool_ = allocate!ACSymbol(Mallocator.it, internString("bool"), CompletionKind.keyword);
|
auto bool_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[13], CompletionKind.keyword);
|
||||||
auto int_ = allocate!ACSymbol(Mallocator.it, internString("int"), CompletionKind.keyword);
|
auto int_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[0], CompletionKind.keyword);
|
||||||
auto long_ = allocate!ACSymbol(Mallocator.it, internString("long"), CompletionKind.keyword);
|
auto long_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[8], CompletionKind.keyword);
|
||||||
auto byte_ = allocate!ACSymbol(Mallocator.it, internString("byte"), CompletionKind.keyword);
|
auto byte_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[19], CompletionKind.keyword);
|
||||||
auto char_ = allocate!ACSymbol(Mallocator.it, internString("char"), CompletionKind.keyword);
|
auto char_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[10], CompletionKind.keyword);
|
||||||
auto dchar_ = allocate!ACSymbol(Mallocator.it, internString("dchar"), CompletionKind.keyword);
|
auto dchar_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[12], CompletionKind.keyword);
|
||||||
auto short_ = allocate!ACSymbol(Mallocator.it, internString("short"), CompletionKind.keyword);
|
auto short_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[6], CompletionKind.keyword);
|
||||||
auto ubyte_ = allocate!ACSymbol(Mallocator.it, internString("ubyte"), CompletionKind.keyword);
|
auto ubyte_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[20], CompletionKind.keyword);
|
||||||
auto uint_ = allocate!ACSymbol(Mallocator.it, internString("uint"), CompletionKind.keyword);
|
auto uint_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[1], CompletionKind.keyword);
|
||||||
auto ulong_ = allocate!ACSymbol(Mallocator.it, internString("ulong"), CompletionKind.keyword);
|
auto ulong_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[9], CompletionKind.keyword);
|
||||||
auto ushort_ = allocate!ACSymbol(Mallocator.it, internString("ushort"), CompletionKind.keyword);
|
auto ushort_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[7], CompletionKind.keyword);
|
||||||
auto wchar_ = allocate!ACSymbol(Mallocator.it, internString("wchar"), CompletionKind.keyword);
|
auto wchar_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[11], CompletionKind.keyword);
|
||||||
|
|
||||||
auto alignof_ = allocate!ACSymbol(Mallocator.it, internString("alignof"), CompletionKind.keyword);
|
auto alignof_ = allocate!ACSymbol(Mallocator.it, internString("alignof"), CompletionKind.keyword);
|
||||||
auto mangleof_ = allocate!ACSymbol(Mallocator.it, internString("mangleof"), CompletionKind.keyword);
|
auto mangleof_ = allocate!ACSymbol(Mallocator.it, internString("mangleof"), CompletionKind.keyword);
|
||||||
|
@ -619,17 +619,17 @@ static this()
|
||||||
s.parts.insert(init);
|
s.parts.insert(init);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cdouble_ = allocate!ACSymbol(Mallocator.it, internString("cdouble"), CompletionKind.keyword);
|
auto cdouble_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[21], CompletionKind.keyword);
|
||||||
auto cent_ = allocate!ACSymbol(Mallocator.it, internString("cent"), CompletionKind.keyword);
|
auto cent_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[15], CompletionKind.keyword);
|
||||||
auto cfloat_ = allocate!ACSymbol(Mallocator.it, internString("cfloat"), CompletionKind.keyword);
|
auto cfloat_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[22], CompletionKind.keyword);
|
||||||
auto creal_ = allocate!ACSymbol(Mallocator.it, internString("creal"), CompletionKind.keyword);
|
auto creal_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[23], CompletionKind.keyword);
|
||||||
auto double_ = allocate!ACSymbol(Mallocator.it, internString("double"), CompletionKind.keyword);
|
auto double_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[2], CompletionKind.keyword);
|
||||||
auto float_ = allocate!ACSymbol(Mallocator.it, internString("float"), CompletionKind.keyword);
|
auto float_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[4], CompletionKind.keyword);
|
||||||
auto idouble_ = allocate!ACSymbol(Mallocator.it, internString("idouble"), CompletionKind.keyword);
|
auto idouble_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[3], CompletionKind.keyword);
|
||||||
auto ifloat_ = allocate!ACSymbol(Mallocator.it, internString("ifloat"), CompletionKind.keyword);
|
auto ifloat_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[5], CompletionKind.keyword);
|
||||||
auto ireal_ = allocate!ACSymbol(Mallocator.it, internString("ireal"), CompletionKind.keyword);
|
auto ireal_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[18], CompletionKind.keyword);
|
||||||
auto real_ = allocate!ACSymbol(Mallocator.it, internString("real"), CompletionKind.keyword);
|
auto real_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[17], CompletionKind.keyword);
|
||||||
auto ucent_ = allocate!ACSymbol(Mallocator.it, internString("ucent"), CompletionKind.keyword);
|
auto ucent_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[16], CompletionKind.keyword);
|
||||||
|
|
||||||
ACSymbol*[11] floatTypeArray;
|
ACSymbol*[11] floatTypeArray;
|
||||||
floatTypeArray[0] = cdouble_;
|
floatTypeArray[0] = cdouble_;
|
||||||
|
@ -689,7 +689,7 @@ static this()
|
||||||
ifloat_.parts.insert(allocate!ACSymbol(Mallocator.it, internString("re"), CompletionKind.keyword, float_));
|
ifloat_.parts.insert(allocate!ACSymbol(Mallocator.it, internString("re"), CompletionKind.keyword, float_));
|
||||||
idouble_.parts.insert(allocate!ACSymbol(Mallocator.it, internString("re"), CompletionKind.keyword, double_));
|
idouble_.parts.insert(allocate!ACSymbol(Mallocator.it, internString("re"), CompletionKind.keyword, double_));
|
||||||
|
|
||||||
auto void_ = allocate!ACSymbol(Mallocator.it, internString("void"), CompletionKind.keyword);
|
auto void_ = allocate!ACSymbol(Mallocator.it, builtinTypeNames[14], CompletionKind.keyword);
|
||||||
|
|
||||||
builtinSymbols.insert(bool_);
|
builtinSymbols.insert(bool_);
|
||||||
bool_.type = bool_;
|
bool_.type = bool_;
|
||||||
|
|
|
@ -870,12 +870,19 @@ class InitializerVisitor : ASTVisitor
|
||||||
semanticSymbol.initializer.insert(internString("[]"));
|
semanticSymbol.initializer.insert(internString("[]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visit(const ArgumentList) {}
|
override void visit(const Initializer initializer)
|
||||||
|
|
||||||
override void visit(const Expression initializer)
|
|
||||||
{
|
{
|
||||||
on = true;
|
on = true;
|
||||||
initializer.accept(this);
|
initializer.accept(this);
|
||||||
|
on = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
override void visit(const ArgumentList) {}
|
||||||
|
|
||||||
|
override void visit(const Expression expression)
|
||||||
|
{
|
||||||
|
on = true;
|
||||||
|
expression.accept(this);
|
||||||
if (appendForeach)
|
if (appendForeach)
|
||||||
semanticSymbol.initializer.insert(internString("foreach"));
|
semanticSymbol.initializer.insert(internString("foreach"));
|
||||||
on = false;
|
on = false;
|
||||||
|
|
|
@ -54,8 +54,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
rootSymbol.acSymbol.parts.insert(builtinSymbols[]);
|
|
||||||
assignToScopes(rootSymbol.acSymbol);
|
assignToScopes(rootSymbol.acSymbol);
|
||||||
|
moduleScope.symbols.insert(builtinSymbols[]);
|
||||||
resolveImports(moduleScope);
|
resolveImports(moduleScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,7 @@ private:
|
||||||
slice.popFront();
|
slice.popFront();
|
||||||
literal = false;
|
literal = false;
|
||||||
}
|
}
|
||||||
|
immutable string leftmostType = literal ? slice.front[1 .. $] : slice.front;
|
||||||
auto symbols = moduleScope.getSymbolsByNameAndCursor(internString(
|
auto symbols = moduleScope.getSymbolsByNameAndCursor(internString(
|
||||||
literal ? slice.front[1 .. $] : slice.front), location);
|
literal ? slice.front[1 .. $] : slice.front), location);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
identifiers
|
||||||
|
alignof k
|
||||||
|
init k
|
||||||
|
mangleof k
|
||||||
|
max k
|
||||||
|
min k
|
||||||
|
sizeof k
|
||||||
|
stringof k
|
|
@ -0,0 +1,9 @@
|
||||||
|
identifiers
|
||||||
|
alignof k
|
||||||
|
init k
|
||||||
|
mangleof k
|
||||||
|
sizeof k
|
||||||
|
stringof k
|
||||||
|
tupleof k
|
||||||
|
x v
|
||||||
|
y v
|
|
@ -0,0 +1,8 @@
|
||||||
|
identifiers
|
||||||
|
alignof k
|
||||||
|
init k
|
||||||
|
mangleof k
|
||||||
|
max k
|
||||||
|
min k
|
||||||
|
sizeof k
|
||||||
|
stringof k
|
|
@ -0,0 +1,9 @@
|
||||||
|
identifiers
|
||||||
|
alignof k
|
||||||
|
init k
|
||||||
|
mangleof k
|
||||||
|
sizeof k
|
||||||
|
stringof k
|
||||||
|
tupleof k
|
||||||
|
x v
|
||||||
|
y v
|
|
@ -0,0 +1,23 @@
|
||||||
|
struct S { int x; int y; }
|
||||||
|
|
||||||
|
S doStuff(int x) { return S(); }
|
||||||
|
|
||||||
|
void main(string[] args)
|
||||||
|
{
|
||||||
|
auto a = 10;
|
||||||
|
auto b = S(1, 2);
|
||||||
|
int c = 4;
|
||||||
|
auto d = doStuff();
|
||||||
|
{
|
||||||
|
a.
|
||||||
|
}
|
||||||
|
{
|
||||||
|
b.
|
||||||
|
}
|
||||||
|
{
|
||||||
|
c.
|
||||||
|
}
|
||||||
|
{
|
||||||
|
d.
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
dcd-client file.d -c162 > actual1.txt
|
||||||
|
diff actual1.txt expected1.txt
|
||||||
|
|
||||||
|
dcd-client file.d -c173 > actual2.txt
|
||||||
|
diff actual2.txt expected2.txt
|
||||||
|
|
||||||
|
dcd-client file.d -c184 > actual3.txt
|
||||||
|
diff actual3.txt expected3.txt
|
||||||
|
|
||||||
|
dcd-client file.d -c195 > actual4.txt
|
||||||
|
diff actual4.txt expected4.txt
|
Loading…
Reference in New Issue