Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive flatten syntax-rules macro crashes NodeJS #304

Closed
Tracked by #43
jcubic opened this issue Feb 4, 2024 · 0 comments
Closed
Tracked by #43

Recursive flatten syntax-rules macro crashes NodeJS #304

jcubic opened this issue Feb 4, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@jcubic
Copy link
Collaborator

jcubic commented Feb 4, 2024

This is the result of running macro:

(define-syntax flatten
  (syntax-rules (aux reverse)
    ((_ xs)
     (flatten aux xs ()))
    ((_ aux ((xs ...) ys ...) (result ...))
     (flatten aux (xs ... ys ...) (result ...)))
    ((_ aux (x xs ...) (result ...))
     (flatten aux (xs ...) (x result ...)))
    ((_ aux () (result ...))
     (flatten reverse (result ...) ()))
    ((_ reverse () (result ...))
     '(result ...))
    ((_ reverse (x xs ...) (result ...))
     (flatten reverse (xs ...) (x result ...)))))

(print (flatten ((1 2 (a b) (c d)) (3 4 (e f) (g h)))))

Przechwycenie obrazu ekranu_2024-02-02_17-07-50

Bun on the other hand creates a very long expansion and probably throws StackOverflow:

Przechwycenie obrazu ekranu_2024-02-04_13-39-43

@jcubic jcubic added the bug Something isn't working label Feb 4, 2024
@jcubic jcubic added this to the 1.0 milestone Feb 4, 2024
@jcubic jcubic mentioned this issue Feb 4, 2024
39 tasks
jcubic added a commit that referenced this issue Feb 4, 2024
@jcubic jcubic closed this as completed Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant