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

Await should not affect original quoted promises #153

Closed
jcubic opened this issue Apr 2, 2021 · 4 comments
Closed

Await should not affect original quoted promises #153

jcubic opened this issue Apr 2, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@jcubic
Copy link
Collaborator

jcubic commented Apr 2, 2021

Description

Await seems to affect original quoted promise in variable

Steps to reproduce:

(let ((x '>(new Promise (lambda (r) (setTimeout (lambda () (r "hello")) 1000)))))
  (print x)
  (print (await x))
  x)
;; ==> #<js-promise (pending)>
;; ==> hello
;; ==> "hello"
(let ((x '>(new Promise (lambda (r) (setTimeout (lambda () (r "hello")) 1000)))))
  (print (await x))
  (type x))
;; ==> hello
;; ==> "promise"
@jcubic jcubic added the bug Something isn't working label Apr 2, 2021
@jcubic
Copy link
Collaborator Author

jcubic commented Apr 2, 2021

The problem seems to be with let:

lips> (let ((x x)) (await x) x)
"hello"
lips> (let ((x x)) (await x) (list x))
(#<js-promise resolved (string)>)

@jcubic
Copy link
Collaborator Author

jcubic commented Apr 2, 2021

this is not related to let:

lips> (begin (print (await x)) x)
hello
"hello"
lips> ((lambda () (print (await x)) x))
hello
"hello"

@jcubic
Copy link
Collaborator Author

jcubic commented Apr 2, 2021

The issue is not with macros:

(define value '>(timer 100 "hello world"))
(define-macro (x . body) `(list ,@body))
(x (await value) value)
;; ==> ("hello world" #<js-promise resolved (string)>)

jcubic added a commit that referenced this issue Apr 6, 2021
Handle case when macro begin evaluate promise and quoted promise in same expression
@jcubic
Copy link
Collaborator Author

jcubic commented Apr 6, 2021

The problem was that Promise handle promise like objects like real promises, so if promise resolve to quoted promise, it will resolve to the value of quoted promise not to quoted Promise.

jcubic added a commit that referenced this issue Apr 6, 2021
Handle case when macro begin evaluate promise and quoted promise in same expression
@jcubic jcubic closed this as completed Apr 6, 2021
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