Skip to content

CyclicDependencyError #655

Closed
Closed

Description

@Frotty

In LinkedList.wurst, when changing
function foldl<Q>(Q startValue, FoldClosure<T, Q> predicate) returns Q
to
function foldl<Q, T>(Q startValue, FoldClosure<T, Q> predicate) returns Q

de.peeeq.wurstscript.ast.CyclicDependencyError
	at de.peeeq.wurstscript.ast.WShortParameterImpl.attrTyp(WShortParameterImpl.java:189)
	at de.peeeq.wurstscript.attributes.Generics.lambda$inferTypeParametersUsingArguments$0(Generics.java:61)
	at de.peeeq.wurstscript.types.WurstTypeDeferred.force(WurstTypeDeferred.java:63)
	at de.peeeq.wurstscript.types.WurstTypeDeferred.isSubtypeOfIntern(WurstTypeDeferred.java:30)
	at de.peeeq.wurstscript.types.WurstType.isSubtypeOf(WurstType.java:40)
	at de.peeeq.wurstscript.types.WurstType.isSubtypeOf(WurstType.java:26)
	at de.peeeq.wurstscript.types.WurstType.equalsType(WurstType.java:71)
	at de.peeeq.wurstscript.attributes.Generics.inferTypeParameters(Generics.java:97)
	at de.peeeq.wurstscript.attributes.Generics.inferTypeParameters(Generics.java:90)
	at de.peeeq.wurstscript.attributes.Generics.inferTypeParameters(Generics.java:90)
	at de.peeeq.wurstscript.attributes.Generics.inferTypeParameters(Generics.java:120)
	at de.peeeq.wurstscript.attributes.Generics.inferTypeParametersUsingArguments(Generics.java:70)
	at de.peeeq.wurstscript.attributes.Generics.getTypeParameterBindings(Generics.java:31)
	at de.peeeq.wurstscript.ast.ExprFunctionCallImpl.attrTypeParameterBindings(ExprFunctionCallImpl.java:500)
	at de.peeeq.wurstscript.attributes.AttrPossibleFunctionSignatures.calculate(AttrPossibleFunctionSignatures.java:27)
	at de.peeeq.wurstscript.ast.ExprFunctionCallImpl.attrPossibleFunctionSignatures(ExprFunctionCallImpl.java:450)
	at de.peeeq.wurstscript.attributes.AttrExprExpectedType.expectedType(AttrExprExpectedType.java:129)
	at de.peeeq.wurstscript.attributes.AttrExprExpectedType.calculate(AttrExprExpectedType.java:29)
	at de.peeeq.wurstscript.ast.ExprClosureImpl.attrExpectedTypRaw(ExprClosureImpl.java:261)
	at de.peeeq.wurstscript.attributes.AttrExprExpectedType.normalizedType(AttrExprExpectedType.java:146)
	at de.peeeq.wurstscript.ast.ExprClosureImpl.attrExpectedTyp(ExprClosureImpl.java:275)
	at de.peeeq.wurstscript.attributes.AttrVarDefType.calculate(AttrVarDefType.java:44)
	at de.peeeq.wurstscript.ast.WShortParameterImpl.attrTyp(WShortParameterImpl.java:186)
	at de.peeeq.wurstscript.validation.controlflow.DataflowAnomalyAnalysis.checkIfVarsInitialized(DataflowAnomalyAnalysis.java:318)
	at de.peeeq.wurstscript.validation.controlflow.DataflowAnomalyAnalysis.calculate(DataflowAnomalyAnalysis.java:248)
	at de.peeeq.wurstscript.validation.controlflow.DataflowAnomalyAnalysis.calculate(DataflowAnomalyAnalysis.java:220)
	at de.peeeq.wurstscript.validation.controlflow.ForwardExecution.checkStmt(ForwardExecution.java:52)
	at de.peeeq.wurstscript.validation.controlflow.ForwardExecution.execute(ForwardExecution.java:31)
	at de.peeeq.wurstscript.validation.controlflow.ForwardMethod.execute(ForwardMethod.java:41)
	at de.peeeq.wurstscript.validation.WurstValidator.checkUninitializedVars(WurstValidator.java:1061)
	at de.peeeq.wurstscript.validation.WurstValidator.check(WurstValidator.java:270)
	at de.peeeq.wurstscript.validation.WurstValidator.walkTree(WurstValidator.java:207)
	at de.peeeq.wurstscript.validation.WurstValidator.walkTree(WurstValidator.java:210)
	at de.peeeq.wurstscript.validation.WurstValidator.walkTree(WurstValidator.java:210)
	at de.peeeq.wurstscript.validation.WurstValidator.walkTree(WurstValidator.java:210)
	at de.peeeq.wurstscript.validation.WurstValidator.walkTree(WurstValidator.java:210)
	at de.peeeq.wurstscript.validation.WurstValidator.walkTree(WurstValidator.java:210)
	at de.peeeq.wurstscript.validation.WurstValidator.walkTree(WurstValidator.java:210)
	at de.peeeq.wurstscript.validation.WurstValidator.validate(WurstValidator.java:55)
	at de.peeeq.wurstscript.WurstChecker.checkProg(WurstChecker.java:46)
	at de.peeeq.wurstio.WurstCompilerJassImpl.checkProg(WurstCompilerJassImpl.java:326)
	at de.peeeq.wurstio.WurstCompilerJassImpl.checkProg(WurstCompilerJassImpl.java:314)
	at de.peeeq.wurstio.languageserver.ModelManagerImpl.doTypeCheck(ModelManagerImpl.java:282)
	at de.peeeq.wurstio.languageserver.ModelManagerImpl.buildProject(ModelManagerImpl.java:116)
	at de.peeeq.wurstio.languageserver.LanguageWorker.doInit(LanguageWorker.java:208)
	at de.peeeq.wurstio.languageserver.LanguageWorker.lambda$getNextWorkItem$0(LanguageWorker.java:163)
	at de.peeeq.wurstio.languageserver.LanguageWorker$Workitem.run(LanguageWorker.java:28)
	at de.peeeq.wurstio.languageserver.LanguageWorker.run(LanguageWorker.java:145)
	at java.lang.Thread.run(Unknown Source)
Mai 16, 2018 1:38:32 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SEVERE: Internal error: de.peeeq.wurstscript.ast.CyclicDependencyError
java.util.concurrent.CompletionException: de.peeeq.wurstscript.ast.CyclicDependencyError
	at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
	at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
	at java.util.concurrent.CompletableFuture.uniApply(Unknown Source)
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
	at java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)
	at de.peeeq.wurstio.languageserver.requests.UserRequest.handleException(UserRequest.java:40)
	at de.peeeq.wurstio.languageserver.LanguageWorker.lambda$handle$3(LanguageWorker.java:272)
	at java.util.concurrent.CompletableFuture.uniWhenComplete(Unknown Source)
	at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(Unknown Source)
	at java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
	at java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)
	at de.peeeq.wurstio.languageserver.requests.UserRequest.run(UserRequest.java:34)
	at de.peeeq.wurstio.languageserver.LanguageWorker.lambda$getNextWorkItem$1(LanguageWorker.java:170)
	at de.peeeq.wurstio.languageserver.LanguageWorker$Workitem.run(LanguageWorker.java:28)
	at de.peeeq.wurstio.languageserver.LanguageWorker.run(LanguageWorker.java:145)
	at java.lang.Thread.run(Unknown Source)
Caused by: de.peeeq.wurstscript.ast.CyclicDependencyError
	at de.peeeq.wurstscript.ast.ExprFunctionCallImpl.attrPossibleFunctionSignatures(ExprFunctionCallImpl.java:453)
	at de.peeeq.wurstscript.attributes.AttrFunctionSignature.calculate(AttrFunctionSignature.java:15)
	at de.peeeq.wurstscript.ast.ExprFunctionCallImpl.attrFunctionSignature(ExprFunctionCallImpl.java:464)
	at de.peeeq.wurstscript.attributes.AttrExprType.calculate(AttrExprType.java:416)
	at de.peeeq.wurstscript.ast.ExprFunctionCallImpl.attrTypRaw(ExprFunctionCallImpl.java:342)
	at de.peeeq.wurstscript.attributes.AttrExprType.normalizedType(AttrExprType.java:510)
	at de.peeeq.wurstscript.ast.ExprFunctionCallImpl.attrTyp(ExprFunctionCallImpl.java:314)
	at de.peeeq.wurstscript.attributes.AttrVarDefType.defaultCase(AttrVarDefType.java:77)
	at de.peeeq.wurstscript.attributes.AttrVarDefType.calculate(AttrVarDefType.java:24)
	at de.peeeq.wurstscript.ast.LocalVarDefImpl.attrTyp(LocalVarDefImpl.java:300)
	at de.peeeq.wurstscript.attributes.AttrExprType.calculate(AttrExprType.java:73)
	at de.peeeq.wurstscript.ast.ExprVarAccessImpl.attrTypRaw(ExprVarAccessImpl.java:275)
	at de.peeeq.wurstscript.attributes.AttrExprType.normalizedType(AttrExprType.java:510)
	at de.peeeq.wurstscript.ast.ExprVarAccessImpl.attrTyp(ExprVarAccessImpl.java:247)
	at de.peeeq.wurstscript.attributes.AttrFuncDef.calculate(AttrFuncDef.java:76)
	at de.peeeq.wurstscript.ast.ExprMemberMethodDotImpl.attrFuncDef(ExprMemberMethodDotImpl.java:594)
	at de.peeeq.wurstscript.attributes.AttrNameDef.tryGetNameDef(AttrNameDef.java:113)
	at de.peeeq.wurstscript.ast.ExprMemberMethodDotImpl.tryGetNameDef(ExprMemberMethodDotImpl.java:479)
	at de.peeeq.wurstio.languageserver.requests.GetUsages.execute(GetUsages.java:61)
	at de.peeeq.wurstio.languageserver.requests.GetUsages.execute(GetUsages.java:18)
	at de.peeeq.wurstio.languageserver.requests.UserRequest.run(UserRequest.java:31)
	... 4 more

Activity

  1. peq commented on May 16, 2018

    @peq
    Collaborator
  2. Frotty commented on May 16, 2018

    @Frotty
    MemberAuthor

    What call?
    It isn't even called.
    Simply modifying the code this way causes that exception.
    I don't understand the workaround?
    image

  3. peq commented on May 16, 2018

    @peq
    Collaborator

    The error in the screenshot is something different: That is a valid error, because r.elem has type T (the class type parameter T) and run expects a T (the foldl function parameter T). You really should not shadow type parameter names to avoid this confusion -- I can add a warning for this.

    The cyclic dependency error can be worked around by adapting the calls to foldl:

    	/** Prints the content of the list */
    	function toString() returns string
    		let fold = foldl<string,T>("[", (i, q) -> q + (i castTo int).toString() + ",")
    		return fold.substring(0, fold.length()-1) + "]"
    
    
    @Test function testFoldl()
    	var list = new LinkedList<int>()
    	for i = 1 to 6
    		list.add(i)
    	let result = list.foldl<int, int>(0, (i, q) -> q + i)
    	result.assertEquals(21)
    
    @Test function testAsList()
    	asList(1,2,3,4).foldl<int, int>(0, (i, q) -> q + i)
    		.assertEquals(asList(4,3,2,1).foldl<int, int>(0, (i, q) -> q + i))
    

    I hope the bug should be fixed with the type refactoring I am doing currently.

  4. added a commit that references this issue on Jun 13, 2018
  5. peq commented on Jun 13, 2018

    @peq
    Collaborator

    Fixed with #673

  6. added a commit that references this issue on Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions