Skip to content

Commit

Permalink
Merge branch 'aiken-lang:main' into add-completion-install
Browse files Browse the repository at this point in the history
  • Loading branch information
freexploit committed May 8, 2024
2 parents 24560e9 + f8ce46d commit 6df1fcb
Show file tree
Hide file tree
Showing 119 changed files with 4,896 additions and 1,944 deletions.
406 changes: 285 additions & 121 deletions .github/workflows/release.yml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@

- **aiken-lang**: formatter should not erase `pub` on validators. @rvcas
- **aiken-lang**: error on using tuple index when a tuple is returned by a generic function. @rvcas
- **aiken-lang**: fix a regression in the Type-checker introduced in v1.0.25-alpha regarding types comparison. See #917. @KtorZ
- **aiken-lang**: Fix incongruous generics after type-checking which caused [] to be treated as a list in cases where it needed to be an empty map primitive. See #922. @KtorZ
- **aiken-lang**: Fix for generic constrs being used as functions causing type mismatch errors. @Microproofs
- **aiken-lang**: Fix for error occuring when a field holds Data that is not a constr type when compiler traces are on. @Microproofs

### Changed
- **aiken-lang**: **MAJOR CHANGE** 2-tuples are now treated the same as 3+ tuples. To replace the representation of pairs at the uplc level, we now have a new Prelude type called Pair with 2 generic arguments. The main place you will see its usage is in the script context. For existing contracts you can continue to use 2-tuples, just note the offchain representation is an array of 2 items in CBOR. @KtorZ @Microproofs
- **aiken-lang**: Some more code gen cleanup. @Microproofs
- **aiken-lang**: New optimization for wrapped builtins found in the stdlib. @Microproofs


## v1.0.26-alpha - 2024-03-25

Expand Down
33 changes: 30 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,35 @@
members = ["crates/*"]
resolver = "2"

[profile.release]
strip = true

[workspace.metadata.release]
shared-version = true
tag-name = "v{{version}}"

# Config for 'cargo dist'
[workspace.metadata.dist]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.13.3"
# CI backends to support
ci = ["github"]
# The installers to generate for each app
installers = ["shell", "powershell", "npm", "homebrew", "msi"]
# A GitHub repo to push Homebrew formulas to
tap = "aiken-lang/homebrew-tap"
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
# The archive format to use for windows builds (defaults .zip)
windows-archive = ".tar.gz"
# The archive format to use for non-windows builds (defaults .tar.xz)
unix-archive = ".tar.gz"
# A namespace to use when publishing this package to the npm registry
npm-scope = "@aiken-lang"
# Publish jobs to run in CI
publish-jobs = ["homebrew"]
# Publish jobs to run in CI
pr-run-mode = "plan"
# Whether to install an updater program
install-updater = false

[workspace.dependencies]
walkdir = "2.3.2"
pallas = "0.22.0"
Expand All @@ -19,3 +41,8 @@ opt-level = 3

[profile.dev.package.similar]
opt-level = 3

# The profile that 'cargo dist' will build with
[profile.dist]
inherits = "release"
lto = "thin"
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@
identification within third-party archives.

Copyright 2016-2022 Louis Pilfold (as Gleam)
Copyright 2022-Present TxPipe & Lucas Rosa (as Aiken)
Copyright 2022-2024 Cardano Foundation (as Aiken)
Copyright 2024-Present PRAGMA (as Aiken)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
47 changes: 45 additions & 2 deletions crates/aiken-lang/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,12 @@ pub enum Annotation {
location: Span,
elems: Vec<Self>,
},

Pair {
location: Span,
fst: Box<Self>,
snd: Box<Self>,
},
}

impl Annotation {
Expand All @@ -979,7 +985,8 @@ impl Annotation {
| Annotation::Tuple { location, .. }
| Annotation::Var { location, .. }
| Annotation::Hole { location, .. }
| Annotation::Constructor { location, .. } => *location,
| Annotation::Constructor { location, .. }
| Annotation::Pair { location, .. } => *location,
}
}

Expand Down Expand Up @@ -1081,6 +1088,18 @@ impl Annotation {
} => name == o_name,
_ => false,
},
Annotation::Pair { fst, snd, .. } => {
if let Annotation::Pair {
fst: o_fst,
snd: o_snd,
..
} = other
{
fst.is_logically_equal(o_fst) && snd.is_logically_equal(o_snd)
} else {
false
}
}
}
}

Expand All @@ -1101,6 +1120,9 @@ impl Annotation {
elems.iter().find_map(|arg| arg.find_node(byte_index))
}
Annotation::Var { .. } | Annotation::Hole { .. } => None,
Annotation::Pair { fst, snd, .. } => fst
.find_node(byte_index)
.or_else(|| snd.find_node(byte_index)),
};

located.or(Some(Located::Annotation(self)))
Expand Down Expand Up @@ -1225,6 +1247,12 @@ pub enum Pattern<Constructor, Type> {
tipo: Type,
},

Pair {
location: Span,
fst: Box<Self>,
snd: Box<Self>,
},

Tuple {
location: Span,
elems: Vec<Self>,
Expand All @@ -1240,6 +1268,7 @@ impl<A, B> Pattern<A, B> {
| Pattern::List { location, .. }
| Pattern::Discard { location, .. }
| Pattern::Tuple { location, .. }
| Pattern::Pair { location, .. }
| Pattern::Constructor { location, .. } => *location,
}
}
Expand Down Expand Up @@ -1309,6 +1338,19 @@ impl TypedPattern {
_ => None,
},

Pattern::Pair { fst, snd, .. } => match &**value {
Type::Pair {
fst: fst_v,
snd: snd_v,
..
} => [fst, snd]
.into_iter()
.zip([fst_v, snd_v].iter())
.find_map(|(e, t)| e.find_node(byte_index, t))
.or(Some(Located::Pattern(self, value.clone()))),
_ => None,
},

Pattern::Constructor {
arguments, tipo, ..
} => match &**tipo {
Expand All @@ -1322,14 +1364,15 @@ impl TypedPattern {
}
}

// TODO: This function definition is weird, see where this is used and how.
pub fn tipo(&self, value: &TypedExpr) -> Option<Rc<Type>> {
match self {
Pattern::Int { .. } => Some(builtins::int()),
Pattern::Constructor { tipo, .. } => Some(tipo.clone()),
Pattern::Var { .. } | Pattern::Assign { .. } | Pattern::Discard { .. } => {
Some(value.tipo())
}
Pattern::List { .. } | Pattern::Tuple { .. } => None,
Pattern::List { .. } | Pattern::Tuple { .. } | Pattern::Pair { .. } => None,
}
}
}
Expand Down

0 comments on commit 6df1fcb

Please sign in to comment.