Skip to content

Can only remove recursive type definitions on union types not "TypeReference" #119

@fefrei

Description

@fefrei

Starting with version 4.0.0, ts-pegjs fails to handle recursive rules like this:

start = "(" e: start ")" { return e; }

Peggy itself has no issue with this, but ts-pegjs struggles computing the types:

Error: Can only remove recursive type definitions on union types not "TypeReference"
    at getInfoFromDiagnostic (C:\Users\felix\git\pseuco-ccs-interpreter\node_modules\ts-pegjs\dist\tspegjs.js:339:11)
    at C:\Users\felix\git\pseuco-ccs-interpreter\node_modules\ts-pegjs\dist\tspegjs.js:304:41
    at Array.map (<anonymous>)
    at pruneCircularReferences (C:\Users\felix\git\pseuco-ccs-interpreter\node_modules\ts-pegjs\dist\tspegjs.js:304:30)
    at TypeExtractor.getTypes (C:\Users\felix\git\pseuco-ccs-interpreter\node_modules\ts-pegjs\dist\tspegjs.js:482:5)
    at generateParser (C:\Users\felix\git\pseuco-ccs-interpreter\node_modules\ts-pegjs\dist\tspegjs.js:779:35)
    at C:\Users\felix\git\pseuco-ccs-interpreter\node_modules\peggy\lib\compiler\index.js:119:9
    at Array.forEach (<anonymous>)
    at C:\Users\felix\git\pseuco-ccs-interpreter\node_modules\peggy\lib\compiler\index.js:116:21
    at Array.forEach (<anonymous>)

Version 3.1.0 could still handle this.

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