Skip to content

Number literals in custom encoding can't be wrapped #99

Closed
@JohanWiltink

Description

@JohanWiltink

when using a custom numEncoding where fromInt returns a JS function instead of an L:

  • zero = 0 throws "term.free is not a function"
  • zero = I 0 works as expected

wrap calls .free to determine free variables, but JS Functions don't have .free.

When inside a compiled application, .free?.() || [] in A prevents this behaviour. wrap should call term.free?.() ?? [].

ETA: changed not to ?? [] but || new Set. for some reason, ?? isn't used in other places ( ?. requires Node 14, so ?? is available ); free returns a Set; the only reason [] is used in A is it's an immediate argument to union ( which returns a Set but accepts Arrays ), so [] is adequate there, but not here.

L.free has the same problem ( and the same solution ).

TypeError: term.free is not a function
    at wrap (file:///workspace/node_modules/@codewars/lambda-calculus/src/lambda-calculus.js:172:23)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions