diff --git a/CHANGELOG.md b/CHANGELOG.md index 51a6ac63..30d168d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## v1.0.8-alpha - unreleased +## next - 2023-MM-DD ### Added @@ -8,7 +8,10 @@ N/A ### Fixed -- Fixed operator precedences, in particular the pipe operator (`|>`) which is now of the lowest precedence. +- **aiken-lang**: fixed operator precedences, in particular the pipe operator (`|>`) which is now of the lowest precedence. +- **aiken-project**: need to convert to Program before dumping to uplc +- **aiken-lang**: fmt crashing when comment at end of file with no newline + ### Removed diff --git a/crates/aiken-project/src/lib.rs b/crates/aiken-project/src/lib.rs index afa9edf4..2252a626 100644 --- a/crates/aiken-project/src/lib.rs +++ b/crates/aiken-project/src/lib.rs @@ -39,7 +39,7 @@ use std::{ }; use telemetry::EventListener; use uplc::{ - ast::{DeBruijn, Term}, + ast::{DeBruijn, Name, Program, Term}, machine::cost_model::ExBudget, }; @@ -227,8 +227,10 @@ where for validator in &blueprint.validators { let path = dir.clone().join(format!("{}.uplc", validator.title)); - fs::write(&path, validator.program.to_pretty()) - .map_err(|error| Error::FileIo { error, path })?; + let program = &validator.program; + let program: Program = program.try_into().unwrap(); + + fs::write(&path, program.to_pretty()).map_err(|error| Error::FileIo { error, path })?; } Ok(()) diff --git a/crates/uplc/src/ast.rs b/crates/uplc/src/ast.rs index be01f137..646ef411 100644 --- a/crates/uplc/src/ast.rs +++ b/crates/uplc/src/ast.rs @@ -537,6 +537,29 @@ impl TryFrom> for Term { } } +impl TryFrom<&Program> for Program { + type Error = debruijn::Error; + + fn try_from(value: &Program) -> Result { + Ok(Program:: { + version: value.version, + term: (&value.term).try_into()?, + }) + } +} + +impl TryFrom<&Term> for Term { + type Error = debruijn::Error; + + fn try_from(value: &Term) -> Result { + let mut converter = Converter::new(); + + let term = converter.debruijn_to_name(value)?; + + Ok(term) + } +} + impl TryFrom> for Program { type Error = debruijn::Error;