From a70482fddd7a7a26f9665c3beaff53d0056838d6 Mon Sep 17 00:00:00 2001 From: ryuukk Date: Tue, 14 Feb 2023 14:55:12 +0100 Subject: [PATCH] fix tests --- dsymbol/src/dsymbol/conversion/first.d | 38 ++++++++++++++----------- dsymbol/src/dsymbol/conversion/second.d | 11 +++++-- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/dsymbol/src/dsymbol/conversion/first.d b/dsymbol/src/dsymbol/conversion/first.d index 2929082..1c0d6fa 100644 --- a/dsymbol/src/dsymbol/conversion/first.d +++ b/dsymbol/src/dsymbol/conversion/first.d @@ -432,16 +432,6 @@ final class FirstPass : ASTVisitor structFieldTypes.insert(null); } - - // for auto declaration, we'll properly traverse the initializer - // and set the proper crumbs instead of using just the first one - // so we can handle things like cast/templates - auto lookup = symbol.typeLookups.front; - istring[] copy; - foreach(crumb; lookup.breadcrumbs[]) - copy ~= crumb; - lookup.breadcrumbs.clear(); - auto initializer = part.initializer.nonVoidInitializer; if (initializer && initializer.assignExpression) { @@ -451,6 +441,8 @@ final class FirstPass : ASTVisitor if (CastExpression castExpression = unary.castExpression) { warning("cast expression"); + auto lookup = symbol.typeLookups.front; + lookup.breadcrumbs.clear(); if (castExpression.type && castExpression.type.type2) { Type2 t2 = castExpression.type.type2; @@ -459,6 +451,7 @@ final class FirstPass : ASTVisitor buildChain(symbol, lookup, &lookup.ctx, t2.typeIdentifierPart); } } + continue; } else if (FunctionCallExpression fc = unary.functionCallExpression) { @@ -469,8 +462,18 @@ final class FirstPass : ASTVisitor } } - if (unary) + if (unary + && !unary.primaryExpression + && !unary.indexExpression + && !unary.throwExpression + && !unary.assertExpression + && !unary.argumentList + && !unary.deleteExpression + && !unary.newExpression + ) { + auto lookup = symbol.typeLookups.front; + lookup.breadcrumbs.clear(); // build chain traverseUnaryExpression(symbol, lookup, &lookup.ctx, unary); // needs to be reversed because it got added in order (right->left) @@ -509,14 +512,17 @@ final class FirstPass : ASTVisitor } } - if (symbol.acSymbol.name == "it") + if (symbol.acSymbol.name == "b") { import core.stdc.stdlib: exit; + auto lookup = symbol.typeLookups.front; warning("crumb: ", lookup.breadcrumbs[]); - - warning("root: ", lookup.ctx.root.chain); - foreach(arg; lookup.ctx.root.args) - warning(" arg: ", arg.chain); + if (lookup.ctx.root) + { + warning("root: ", lookup.ctx.root.chain); + foreach(arg; lookup.ctx.root.args) + warning(" arg: ", arg.chain); + } //exit(0); } } diff --git a/dsymbol/src/dsymbol/conversion/second.d b/dsymbol/src/dsymbol/conversion/second.d index 2d9eb72..f6a27e9 100644 --- a/dsymbol/src/dsymbol/conversion/second.d +++ b/dsymbol/src/dsymbol/conversion/second.d @@ -70,7 +70,14 @@ void secondPass(SemanticSymbol* currentSymbol, Scope* moduleScope, ref ModuleCac { DSymbol*[string] mapping; int depth; - resolveTemplate(currentSymbol.acSymbol, type, lookup, lookup.ctx.root, moduleScope, cache, depth, mapping); + try + { + resolveTemplate(currentSymbol.acSymbol, type, lookup, lookup.ctx.root, moduleScope, cache, depth, mapping); + } + catch(Exception e) + { + warning("exception: ".red, currentSymbol.acSymbol.name); + } } } } @@ -243,7 +250,7 @@ DSymbol* createTypeWithTemplateArgs(DSymbol* type, TypeLookup* lookup, VariableC if (type.kind == CompletionKind.functionName) { auto callTip = type.callTip; - if (callTip.length > 1) + if (callTip && callTip.length > 1) { auto retType = extractReturnType(callTip); if (retType in mapping)