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

Typehinting async functions before arg vector doesn't (always) work #339

Open
okmaybenot opened this issue Jan 28, 2025 · 0 comments
Open

Comments

@okmaybenot
Copy link

Describe the bug

Examples:

This one works

(defn async-int ^#/(Future int) []
  (dasync/Future.value 1))

This one doesn't

(defn ^:async async-int ^#/(Future int) []
  (dasync/Future.value 1))
Error: A value of type 'FutureOr<Future<int>>' can't be returned from an async function with return type 'Future<int>'.
 - 'Future' is from 'dart:async'.
return ((da.Future.value(1, )) as da.FutureOr<dc.Future<dc.int>>);

Also, sometimes removing ^:async doesn't help:

(defn async-int-after-job ^#/(Future int) []
  (let [value 1
        job (dasync/Future.value true)]
    (await job)
    (dasync/Future.value value)))
Error: A value of type 'FutureOr<Future<int>>' can't be returned from an async function with return type 'Future<int>'.
 - 'Future' is from 'dart:async'.
return ($1 as da.FutureOr<dc.Future<dc.int>>);

But removing type hint (or moving it before name) helps

(defn ^#/(Future int) async-int-after-job []
  (let [value 1
        job (dasync/Future.value true)]
    (await job)
    (dasync/Future.value value)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant