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**: 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
|
- **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
|
## v1.1.9 - 2024-12-13
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use miette::IntoDiagnostic;
|
use miette::{Context, IntoDiagnostic};
|
||||||
use std::{path::PathBuf, println};
|
use std::{path::PathBuf, println};
|
||||||
use uplc::ast::{DeBruijn, Name, NamedDeBruijn, Program};
|
use uplc::ast::{DeBruijn, Name, NamedDeBruijn, Program};
|
||||||
|
|
||||||
|
@ -39,16 +39,14 @@ pub fn exec(
|
||||||
std::fs::read(&input).into_diagnostic()?
|
std::fs::read(&input).into_diagnostic()?
|
||||||
};
|
};
|
||||||
|
|
||||||
let pretty_uplc = match from {
|
let program: Program<Name> = match from {
|
||||||
Format::Name => {
|
Format::Name => {
|
||||||
let program: Program<Name> = if cbor {
|
if cbor {
|
||||||
let mut flat_buffer = Vec::new();
|
let mut flat_buffer = Vec::new();
|
||||||
Program::from_cbor(&bytes, &mut flat_buffer).into_diagnostic()?
|
Program::from_cbor(&bytes, &mut flat_buffer).into_diagnostic()?
|
||||||
} else {
|
} else {
|
||||||
Program::from_flat(&bytes).into_diagnostic()?
|
Program::from_flat(&bytes).into_diagnostic()?
|
||||||
};
|
}
|
||||||
|
|
||||||
program.to_pretty()
|
|
||||||
}
|
}
|
||||||
Format::NamedDebruijn => {
|
Format::NamedDebruijn => {
|
||||||
let program: Program<NamedDeBruijn> = if cbor {
|
let program: Program<NamedDeBruijn> = if cbor {
|
||||||
|
@ -58,9 +56,10 @@ pub fn exec(
|
||||||
Program::from_flat(&bytes).into_diagnostic()?
|
Program::from_flat(&bytes).into_diagnostic()?
|
||||||
};
|
};
|
||||||
|
|
||||||
let program: Program<Name> = program.try_into().unwrap();
|
program
|
||||||
|
.try_into()
|
||||||
program.to_pretty()
|
.into_diagnostic()
|
||||||
|
.context("failed to decode, maybe try `--cbor`")?
|
||||||
}
|
}
|
||||||
Format::Debruijn => {
|
Format::Debruijn => {
|
||||||
let program: Program<DeBruijn> = if cbor {
|
let program: Program<DeBruijn> = if cbor {
|
||||||
|
@ -70,13 +69,14 @@ pub fn exec(
|
||||||
Program::from_flat(&bytes).into_diagnostic()?
|
Program::from_flat(&bytes).into_diagnostic()?
|
||||||
};
|
};
|
||||||
|
|
||||||
let program: Program<Name> = program.try_into().unwrap();
|
program
|
||||||
|
.try_into()
|
||||||
program.to_pretty()
|
.into_diagnostic()
|
||||||
|
.context("failed to decode, maybe try `--cbor`")?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("{pretty_uplc}");
|
println!("{}", program.to_pretty());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,7 +461,12 @@ impl Converter {
|
||||||
|
|
||||||
fn get_unique(&mut self, index: &DeBruijn) -> Result<Unique, Error> {
|
fn get_unique(&mut self, index: &DeBruijn) -> Result<Unique, Error> {
|
||||||
for scope in self.levels.iter().rev() {
|
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) {
|
if let Some(unique) = scope.get_right(&index) {
|
||||||
return Ok(*unique);
|
return Ok(*unique);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"plutusVersion": "v3",
|
"plutusVersion": "v3",
|
||||||
"compiler": {
|
"compiler": {
|
||||||
"name": "Aiken",
|
"name": "Aiken",
|
||||||
"version": "v1.1.6+18054ee"
|
"version": "v1.1.9+2217206"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue