fix: remove unwrap which is causing panics closes #1073
This commit is contained in:
parent
1f1ca4f807
commit
3e2ca757cd
|
@ -7,6 +7,10 @@
|
|||
- **aiken-project**: The `aiken.toml` file no longer supports `v1` and `v2` for the plutus version field. @rvcas
|
||||
- **aiken-project**: `Error::TomlLoading` now looks much better - [see](https://github.com/aiken-lang/aiken/issues/1032#issuecomment-2562122101). @rvcas
|
||||
|
||||
### Fixed
|
||||
|
||||
- **aiken**: Fixed the panic error when using `aiken uplc decode` on cbor encoded flat bytes. @rvcas
|
||||
|
||||
## v1.1.9 - 2024-12-13
|
||||
|
||||
### Added
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use miette::IntoDiagnostic;
|
||||
use miette::{Context, IntoDiagnostic};
|
||||
use std::{path::PathBuf, println};
|
||||
use uplc::ast::{DeBruijn, Name, NamedDeBruijn, Program};
|
||||
|
||||
|
@ -39,16 +39,14 @@ pub fn exec(
|
|||
std::fs::read(&input).into_diagnostic()?
|
||||
};
|
||||
|
||||
let pretty_uplc = match from {
|
||||
let program: Program<Name> = match from {
|
||||
Format::Name => {
|
||||
let program: Program<Name> = if cbor {
|
||||
if cbor {
|
||||
let mut flat_buffer = Vec::new();
|
||||
Program::from_cbor(&bytes, &mut flat_buffer).into_diagnostic()?
|
||||
} else {
|
||||
Program::from_flat(&bytes).into_diagnostic()?
|
||||
};
|
||||
|
||||
program.to_pretty()
|
||||
}
|
||||
}
|
||||
Format::NamedDebruijn => {
|
||||
let program: Program<NamedDeBruijn> = if cbor {
|
||||
|
@ -58,9 +56,10 @@ pub fn exec(
|
|||
Program::from_flat(&bytes).into_diagnostic()?
|
||||
};
|
||||
|
||||
let program: Program<Name> = program.try_into().unwrap();
|
||||
|
||||
program.to_pretty()
|
||||
program
|
||||
.try_into()
|
||||
.into_diagnostic()
|
||||
.context("failed to decode, maybe try `--cbor`")?
|
||||
}
|
||||
Format::Debruijn => {
|
||||
let program: Program<DeBruijn> = if cbor {
|
||||
|
@ -70,13 +69,14 @@ pub fn exec(
|
|||
Program::from_flat(&bytes).into_diagnostic()?
|
||||
};
|
||||
|
||||
let program: Program<Name> = program.try_into().unwrap();
|
||||
|
||||
program.to_pretty()
|
||||
program
|
||||
.try_into()
|
||||
.into_diagnostic()
|
||||
.context("failed to decode, maybe try `--cbor`")?
|
||||
}
|
||||
};
|
||||
|
||||
println!("{pretty_uplc}");
|
||||
println!("{}", program.to_pretty());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -461,7 +461,12 @@ impl Converter {
|
|||
|
||||
fn get_unique(&mut self, index: &DeBruijn) -> Result<Unique, Error> {
|
||||
for scope in self.levels.iter().rev() {
|
||||
let index = Level(self.current_level.0 - index.inner());
|
||||
let index = Level(
|
||||
self.current_level
|
||||
.0
|
||||
.checked_sub(index.inner())
|
||||
.ok_or(Error::FreeIndex(*index))?,
|
||||
);
|
||||
|
||||
if let Some(unique) = scope.get_right(&index) {
|
||||
return Ok(*unique);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"plutusVersion": "v3",
|
||||
"compiler": {
|
||||
"name": "Aiken",
|
||||
"version": "v1.1.6+18054ee"
|
||||
"version": "v1.1.9+2217206"
|
||||
},
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue