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

Red Knot Playground #12681

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Red Knot Playground #12681

wants to merge 8 commits into from

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Aug 5, 2024

Summary

This PR adds a playground for Red Knot

Screencast.from.2024-08-14.10-33-54.webm

Sharing does work 😆 I just forgot to start wrangler.

It supports:

  • Multiple files
  • Showing the AST
  • Showing the tokens
  • Sharing
  • Persistence to local storage

Future extensions:

  • Configuration support: The pyproject.toml would just be another file.
  • Showing type information on hover

Blockers

Salsa uses catch_unwind to break cycles, which Red Knot uses extensively when inferring types in the standard library.
However, WASM (at least wasm32-unknown-unknown) doesn't support catch_unwind today, so the playground always crashes when the type inference encounters a cycle.

I created a discussion in the salsa zulip to see if it would be possible to not use catch unwind to break cycles.

Rust tracking issue for WASM catch unwind support

I tried to build the WASM with the nightly compiler option but ran into problems because wasm-bindgen doesn't support WASM-exceptions. We could try to write the binding code by hand.

Another alternative is to use wasm32-unknown-emscripten but it's rather painful to build

@MichaReiser MichaReiser added the red-knot Multi-file analysis & type inference label Aug 10, 2024
@MichaReiser MichaReiser force-pushed the red-knot-playground branch 4 times, most recently from 1fa1770 to f2582fd Compare August 11, 2024 15:04
Copy link

codspeed-hq bot commented Aug 11, 2024

CodSpeed Performance Report

Merging #12681 will not alter performance

Comparing red-knot-playground (2692d79) with main (7fc39ad)

Summary

✅ 32 untouched benchmarks

Copy link
Contributor

github-actions bot commented Aug 11, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser MichaReiser force-pushed the red-knot-playground branch 2 times, most recently from e73aa07 to 4d4c5c8 Compare August 14, 2024 08:21
@MichaReiser MichaReiser changed the title [WIP] Red Knot Playground Red Knot Playground Aug 14, 2024
.with_writer(
// To avoide trace events in the browser from showing their
// JS backtrace, which is very annoying, in my opinion
MakeConsoleWriter::default().map_trace_level_to(tracing::Level::TRACE),
Copy link
Member Author

Choose a reason for hiding this comment

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

Add a URl param to determine the log level: ?tracing=debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant