Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [release] — 2026-03-26
- Bumped compiler crate version to `0.1.1` in `compiler/v1/Cargo.toml`.
- Fixed `match` on struct instances via struct field patterns.
- Fixed enum variant matching for both qualified (`Enum::Variant`) and unqualified (`Variant`) patterns.
- Improved grouped import diagnostics so missing items highlight the specific missing name.
- Verified nested module resolution where `module/main.rey` imports other local files.
- Fixed numeric semantics by distinguishing `int` and `float` values at runtime:
- `10 / 3` performs integer division.
- `10.0 / 3.0` and `10 / 3.0` perform float division.
- Allowed external mutation of `pub` struct fields (`obj.field = ...`, `obj.field += ...`) and emit a clear error for nested field assignment (`obj.inner.field = ...`) for now.
- Added `rey-compiler/` v5 bootstrap skeleton (API surface only).
- Added `compiler/README.md` to document the v1 Rust interpreter vs bootstrap target.

## [release] — 2026-03-23
- Prepared `v0.1.0` release candidate assets and docs.
- Audited syntax documentation against current parser/runtime behavior.
Expand Down
17 changes: 17 additions & 0 deletions compiler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Compiler Layout

This repo currently contains two compiler tracks:

## `compiler/v1/`
The shipping Rust implementation for Rey v0.

It is a reference interpreter + typechecker + import resolver used for day-to-day
language development and releases.

## `rey-compiler/`
The long-term bootstrap target: a compiler written in Rey ("Rey-in-Rey").

At the moment this is API-only (types + public function signatures) so we can
stabilize the architecture and start iterating once the v1 Rust runtime is
stable enough to host it.

2 changes: 1 addition & 1 deletion compiler/v1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rey-v0"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

description = "Rey v0 reference interpreter"
Expand Down
3 changes: 2 additions & 1 deletion compiler/v1/src/ast/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
pub enum Literal {
String(String),
Char(char),
Number(f64),
Int(i64),
Float(f64),
Bool(bool),
Null,
}
14 changes: 12 additions & 2 deletions compiler/v1/src/ast/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ pub enum FunctionVisibility {

#[derive(Debug, Clone, PartialEq)]
pub enum ImportKind {
FileSymbols { module: String, symbols: Vec<String> },
FileSymbols { module: String, symbols: Vec<ImportName> },
ModuleNamespace { module: String },
ModuleItems { module: String, items: Vec<String> },
ModuleItems { module: String, items: Vec<ImportName> },
}

#[derive(Debug, Clone, PartialEq)]
pub struct ImportName {
pub name: String,
pub span: Span,
}

#[derive(Debug, Clone, PartialEq)]
Expand Down Expand Up @@ -104,6 +110,10 @@ pub struct MatchArm {
#[derive(Debug, Clone, PartialEq)]
pub enum Pattern {
EnumVariant(String, String), // enum_name, variant_name
Struct {
struct_name: String,
fields: Vec<(String, Pattern)>, // field_name -> field_pattern
},
Literal(Literal),
Variable(String),
Wildcard,
Expand Down
36 changes: 18 additions & 18 deletions compiler/v1/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,26 +156,26 @@ impl ResolverState {
}

for symbol in symbols {
if !injectedNames.insert(symbol.clone()) {
if !injectedNames.insert(symbol.name.clone()) {
return Err(CompileError {
title: "import".to_string(),
file: ownerFile.to_path_buf(),
source: ownerSource.to_string(),
span,
message: format!("Duplicate import: '{}'", symbol),
span: symbol.span,
message: format!("Duplicate import: '{}'", symbol.name),
});
}
match imported.localFunctionVisibility.get(&symbol) {
match imported.localFunctionVisibility.get(&symbol.name) {
Some(FunctionVisibility::ExportPub) => {}
Some(FunctionVisibility::Pub) => {
return Err(CompileError {
title: "import".to_string(),
file: ownerFile.to_path_buf(),
source: ownerSource.to_string(),
span,
span: symbol.span,
message: format!(
"Function '{}' exists in '{}' but is 'pub', not 'export pub'",
symbol,
symbol.name,
importFile.display()
),
});
Expand All @@ -185,10 +185,10 @@ impl ResolverState {
title: "import".to_string(),
file: ownerFile.to_path_buf(),
source: ownerSource.to_string(),
span,
span: symbol.span,
message: format!(
"Function '{}' exists in '{}' but is private",
symbol,
symbol.name,
importFile.display()
),
});
Expand All @@ -198,10 +198,10 @@ impl ResolverState {
title: "import".to_string(),
file: ownerFile.to_path_buf(),
source: ownerSource.to_string(),
span,
span: symbol.span,
message: format!(
"Function '{}' not found in file '{}'",
symbol,
symbol.name,
importFile.display()
),
});
Expand Down Expand Up @@ -293,26 +293,26 @@ impl ResolverState {
}
ImportKind::ModuleItems { module, items } => {
for item in items {
if !injectedNames.insert(item.clone()) {
if !injectedNames.insert(item.name.clone()) {
return Err(CompileError {
title: "import".to_string(),
file: ownerFile.to_path_buf(),
source: ownerSource.to_string(),
span,
message: format!("Duplicate import: '{}'", item),
span: item.span,
message: format!("Duplicate import: '{}'", item.name),
});
}

let importFile = self.findModuleItemFile(
currentDir,
&module,
&item,
&item.name,
ownerFile,
ownerSource,
span,
item.span,
)?;
if self.stack.contains(&importFile) {
return Err(self.circularError(ownerFile, ownerSource, span, &importFile));
return Err(self.circularError(ownerFile, ownerSource, item.span, &importFile));
}
let imported = self.resolveFile(&importFile)?;
if !includedFiles.contains(&importFile) {
Expand All @@ -325,11 +325,11 @@ impl ResolverState {
if visibility == FunctionVisibility::ExportPub {
namespaceEntries.push((
name.clone(),
Expr::Variable { name, span },
Expr::Variable { name, span: item.span },
));
}
}
resolved.push(self.namespaceStmt(&item, namespaceEntries, span));
resolved.push(self.namespaceStmt(&item.name, namespaceEntries, item.span));
}
Ok(())
}
Expand Down
Loading
Loading