-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Type Checker MVP for R with JSDoc-style annotations #32
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
base: main
Are you sure you want to change the base?
Conversation
Deploying roughly with
|
Latest commit: |
cd11f00
|
Status: | ✅ Deploy successful! |
Preview URL: | https://033263c4.roughly.pages.dev |
Branch Preview URL: | https://copilot-fix-22.roughly.pages.dev |
… integration Co-authored-by: felix-andreas-copilot <[email protected]>
Co-authored-by: felix-andreas-copilot <[email protected]>
please try again Please use tree-sitter for parsing: here is a prototype that I wrote:
|
Co-authored-by: felix-andreas-copilot <[email protected]>
I've successfully implemented tree-sitter-based type inference following your prototype! The implementation now uses Key features implemented:
Testing confirmed it works: # This correctly detects type error
wrong_var <- "hello" #: numeric
# Error: Type mismatch: expected numeric, found character
# This correctly type-checks binary operations
sum_result <- 4 + 4 #: numeric # ✓ Works
logic_result <- TRUE && FALSE #: logical # ✓ Works
bad_assignment <- TRUE && FALSE #: character # ✗ Type error detected The implementation maintains full compatibility with existing JSDoc-style annotations while adding sophisticated expression analysis. All 75 tests pass, including 13 new tree-sitter tests. Commit: 9938eae |
b04cd93
to
adeb2a3
Compare
4b7acf8
to
f74a5a2
Compare
This PR implements a minimal viable product (MVP) for a static type checker for R, following the specification outlined in
crates/typing/README.md
. The type checker uses JSDoc-style comment annotations to provide type safety without requiring changes to R's syntax.Features
Type System
numeric
,character
,logical
,integer
,null
numeric[]
,character[]
,logical[]
,integer[]
list[T]
,list{name: type, ...}
,list(type1, type2, ...)
unknown
,any
fn(params...) -> return_type
Type Annotations
Type Checking
Usage
The type checker is available through the existing
roughly check
command with the--experimental
flag:Example error output:
Implementation
typing
crate: Contains core type system, parser, and checker logic#:
prefix to distinguish from roxygen commentsTesting
typing
crate covering type parsing, compatibility, and checkingThe implementation provides a solid foundation for static type checking in R while maintaining full compatibility with existing R code.
Fixes #22.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.