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
14 changes: 12 additions & 2 deletions doc/architecture.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Architecture Note: Omitted Keywords
# Architecture Notes

## Omitted Keywords

The `crate` and `super` keywords were not added to the compiler because they
are unnecessary at this stage. Typically, they are used to resolve relative
paths during import parsing. However, in our architecture, the prefix before
the first `::` in a `use` statement is always an dependency root path. Since all
dependency root paths are unique and strictly bound to specific paths, the resolver
can always unambiguously resolve the path without needing relative pointers.

# Architecture Note: Namespace Separation in SimplicityHL
## Namespace Separation in SimplicityHL

SimplicityHL uses distinct namespaces for types and values. This allows the same identifier to refer to different things depending on where it appears in the code — the compiler determines the correct interpretation from syntactic context, with no risk of collision.

Expand All @@ -19,3 +22,10 @@ fn main() {
assert!(foo()); // value namespace - function
}
```

## The "main" identifier in aliases

In SimplicityHL, the string "main" is reserved exclusively for the program's entry point function.
While a `TypeAlias` is technically allowed to use this name, we explicitly forbid aliasing imports
to "main" using the `as` keyword. This avoids complicating the compiler's resolution logic and
prevents accidental shadowing of the entry point.
17 changes: 14 additions & 3 deletions fuzz/fuzz_targets/compile_parse_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,27 @@
#[cfg(any(fuzzing, test))]
fn do_test(data: &[u8]) {
use arbitrary::Arbitrary;
use std::sync::Arc;

use simplicityhl::error::WithContent;
use simplicityhl::{ast, named, parse, ArbitraryOfType, Arguments};
use simplicityhl::error::{ErrorCollector, WithContent};
use simplicityhl::{ast, driver, named, parse, ArbitraryOfType, Arguments};

let mut u = arbitrary::Unstructured::new(data);
let parse_program = match parse::Program::arbitrary(&mut u) {
Ok(x) => x,
Err(_) => return,
};
let ast_program = match ast::Program::analyze(&parse_program) {

let mut error_handler = ErrorCollector::new();
let driver_program = if let Some(program) =
driver::Program::from_parse(&parse_program, Arc::from(""), &mut error_handler)
{
program
} else {
return;
};

let ast_program = match ast::Program::analyze(&driver_program) {
Ok(x) => x,
Err(_) => return,
};
Expand Down
Loading
Loading