Skip to content

[bug] Resource referring to self in params or results causes a stack overflow #77

@JonasKruckenberg

Description

@JonasKruckenberg

When referring to self i.e. the current resource from a method parameter or result then this causes a stack overflow in the type resolver. The issue is caused by not having the resource name cached when we first encounter it and since it's a recursive reference we spin into a stack overflow.

Reproduction

interface foo {
   resource a {
      constructor() -> a
   }
}

Solution

Refactor the resolver to a 2 stage setup:

  1. resolve all the names, check for duplicate or undefined names
  2. expand all the type definitions

This way, during type expansion we already have a reference to the resource and are not infinitely trying to resolve the name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions