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

ReferenceError: $std_time_timestamp is not defined #638

Open
osa1 opened this issue Dec 23, 2024 · 2 comments
Open

ReferenceError: $std_time_timestamp is not defined #638

osa1 opened this issue Dec 23, 2024 · 2 comments

Comments

@osa1
Copy link
Contributor

osa1 commented Dec 23, 2024

I'm now on dev branch, commit a7c4292.

import std/num/int32
import std/time/duration

alias io = <ndet,div,console,st<global>>

alias result<a> = either<exception,a>

alias async-resume<a> = result<a> -> io ()

alias initiate<a> = async-resume<a> -> io ()

alias async-resume1<a> = a -> io ()

alias initiate1<a> = async-resume1<a> -> io ()

alias async-resume0 = () -> io ()

alias initiate0 = async-resume0 -> io ()

effect async
  ctl await(initiate: initiate<a>): result<a>

fun await1(initiate: initiate1<a>): <async,exn> a
  val await-ret = await fn(async-resume) initiate(fn(x) async-resume(Right(x)))
  match await-ret
    Left(e) -> throw-exn(e)
    Right(a) -> return a

fun await0(initiate: initiate0): <async,exn> ()
  await1 fn(async-resume) initiate(fn() async-resume(()))

fun wait(dur: duration): <async,exn> ()
  await0 fn(res)
    set-timeout(res, dur.milli-seconds.int32)

extern set-timeout(cb: () -> io (), ms: int32) : io ()
  js inline "setTimeout(#1, #2)"

val async-handler = handler
  ctl await(initiate)
    initiate(resume)

fun main()
  with async-handler
  try({ wait(3.seconds) })
  ()

Output:

file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/async.mjs:172
          return $std_time_timestamp.int_fs_timespan(n, _x4);
          ^

ReferenceError: $std_time_timestamp is not defined
    at file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/async.mjs:172:11
    at Module._open_none1 (file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/std_core_hnd.mjs:1396:11)
    at file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/async.mjs:169:37
    at file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/std_core_exn.mjs:330:23
    at Module._hhandle (file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/std_core_hnd.mjs:653:37)
    at exn_fs__handle (file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/std_core_exn.mjs:177:24)
    at Module.$try (file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/std_core_exn.mjs:322:10)
    at file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/async.mjs:167:33
    at Module._hhandle (file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/std_core_hnd.mjs:653:37)
    at async_fs__handle (file:///home/omer/koka/why-effects/.koka/v3.1.3/js-debug-2828eb/async.mjs:53:24)

Node.js v22.11.0
@osa1
Copy link
Contributor Author

osa1 commented Dec 23, 2024

This seems like a bug in tracking or handling or transitive dependencies. If I add the imports:

import std/num/ddouble
import std/time/timestamp

it works.

@TimWhiting
Copy link
Collaborator

Yeah, this happens in the C backend as well with the time libraries. I think it has to do with the main function being split into it's own module at compile time (which is how we handle being able to run test- example- and main functions for the language server / vscode extension).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants