Skip to content

Conversation

fhammerschmidt
Copy link
Member

Vibecoded examples of course, sorry!

// Let's add the examples inside a Test module because some examples
// have type definitions that are not supported inside a block.
// Also add unit type `()`
// Also add unit type `()`. Also wrap in async to make top-level awaits work.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be controversial, but all tests pass.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there is no noticeable performance difference from this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope:

master

node scripts/test.js -docstrings  8.49s user 2.25s system 365% cpu 2.938 total

fix-result-examples

node scripts/test.js -docstrings  8.44s user 2.04s system 357% cpu 2.933 total

Copy link

pkg-pr-new bot commented Sep 20, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7914

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7914

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7914

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7914

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7914

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7914

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7914

commit: dfb2f84

// Let's add the examples inside a Test module because some examples
// have type definitions that are not supported inside a block.
// Also add unit type `()`
// Also add unit type `()`. Also wrap in async to make top-level awaits work.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there is no noticeable performance difference from this?

@zth
Copy link
Member

zth commented Sep 21, 2025

I'm fine with this as-is, can't imagine the perf overhead would be something we need to care about. But if we wanted to care, a quick optimization could be to only wrap if the generated JS text contains await .

@fhammerschmidt fhammerschmidt merged commit 1a8dfdb into master Sep 21, 2025
25 checks passed
@fhammerschmidt fhammerschmidt deleted the fix-result-examples branch September 21, 2025 07:54
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

Successfully merging this pull request may close these issues.

3 participants