timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

Error: no generic parameters allowed for Future #740

Open juancarlospaco opened 3 years ago

juancarlospaco commented 3 years ago

When a proc returns Future[something] Nim does not allow you to use argument: auto in the arguments, this does not make sense at all for JavaScript targets, it makes sense for other backends tho, would be great if this restriction can be removed when compiling to Javascript.

import std/asyncjs

func setTimeoutPromise*(delay: cint; value: auto): Future[cint] {.importjs: "timersPromises.setTimeout(#, #)".}

Complains Error: no generic parameters allowed for Future.

Alternatively the Error can be converted to Warning.

https://github.com/nim-lang/Nim/blob/39ad9a69a9473aa88d4457039393f6ed15fafcfa/compiler/semtypes.nim#L40

https://github.com/nim-lang/Nim/blob/39ad9a69a9473aa88d4457039393f6ed15fafcfa/compiler/semtypes.nim#L1459

https://github.com/juancarlospaco/nodejs/runs/2634488564#step:4:215

https://github.com/juancarlospaco/nodejs/blob/5ecccefe2caf9f2e75596c54395031883528f02f/src/nodejs/jstimers.nim#L40-L49

Repro code not too relevant, because by design conceptually the restriction does not make sense for JavaScript whatsoever.

tandy-1000 commented 2 years ago

why isnt this a mainline issue?