merge master, fix tests

This commit is contained in:
gluaxspeed 2021-08-04 17:30:54 -07:00
commit 003faed13a
76 changed files with 936 additions and 658 deletions

View File

@ -5,7 +5,7 @@ commands:
parameters: parameters:
cache_key: cache_key:
type: string type: string
default: leo-stable-cache default: leo-stable-linux-cache
steps: steps:
- run: set -e - run: set -e
- setup_remote_docker - setup_remote_docker
@ -31,7 +31,7 @@ commands:
parameters: parameters:
cache_key: cache_key:
type: string type: string
default: leo-stable-cache default: leo-stable-linux-cache
steps: steps:
- run: (sccache -s||true) - run: (sccache -s||true)
- run: set +e - run: set +e
@ -40,25 +40,81 @@ commands:
paths: paths:
- .cache/sccache - .cache/sccache
- .cargo - .cargo
jobs: # orbs:
# codecov: codecov/codecov@1.2.3
rust-stable: jobs:
check-style:
docker: docker:
- image: cimg/rust:1.53 - image: cimg/rust:1.53
resource_class: xlarge resource_class: xlarge
steps: steps:
- checkout - checkout
- setup_environment: - setup_environment:
cache_key: leo-stable-cache cache_key: leo-fmt-cache
- run: - run:
name: Build and run tests name: Check style
no_output_timeout: 30m no_output_timeout: 35m
command: cargo test --all command: cargo fmt --all -- --check
- persist_to_workspace:
root: ~/
paths: project/
- clear_environment: - clear_environment:
cache_key: leo-stable-cache cache_key: leo-fmt-cache
clippy:
docker:
- image: cimg/rust:1.53
resource_class: xlarge
steps:
- checkout
- setup_environment:
cache_key: leo-clippy-cache
- run:
name: Clippy
no_output_timeout: 35m
command: cargo clippy --all-features --examples --all --benches
- clear_environment:
cache_key: leo-clippy-cache
# code-cov:
# docker:
# - image: cimg/rust:1.53.0
# resource_class: xlarge
# environment:
# RUSTC_BOOTSTRAP: 1
# steps:
# - checkout
# - setup_environment:
# cache_key: leo-codecov-cache
# - run:
# name: Build and run tests
# no_output_timeout: 30m
# command: cargo test --all
# - run:
# name: Install Code Cov Deps
# no_output_timeout: 30m
# command: |
# sudo apt-get update
# sudo apt-get -y install binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
# - run:
# name: Generate Coverage Report
# no_output_timeout: 30m
# command: |
# wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz
# tar xzf master.tar.gz
# cd kcov-master
# mkdir build && cd build
# cmake .. && make
# make install DESTDIR=../../kcov-build
# cd ../..
# rm -rf kcov-master
# for file in target/debug/deps/*-*; do if [[ "$file" != *\.* ]]; then mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --exclude-region='@kcov_skip(start):@kcov_skip(end)' --verify "target/cov/$(basename $file)" "$file"; fi done
# steps:
# - codecov/upload:
# file: {{}}
# - persist_to_workspace:
# root: ~/
# paths: project/
# - clear_environment:
# cache_key: leo-codecov-cache
leo-executable: leo-executable:
docker: docker:
@ -199,7 +255,8 @@ workflows:
version: 2 version: 2
main-workflow: main-workflow:
jobs: jobs:
- rust-stable - check-style
- clippy
- leo-executable - leo-executable
- leo-new: - leo-new:
requires: requires:

View File

@ -5,7 +5,7 @@ updates:
schedule: schedule:
interval: daily interval: daily
time: "10:00" time: "10:00"
open-pull-requests-limit: 10 open-pull-requests-limit: 20
ignore: ignore:
- dependency-name: snarkvm-curves - dependency-name: snarkvm-curves
versions: versions:

View File

@ -13,80 +13,85 @@ env:
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
jobs: jobs:
style: test-package:
name: Check Style name: Test Package ${{ matrix.os }}
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
steps: strategy:
- name: Checkout matrix:
uses: actions/checkout@v1 os: [macOS-latest, windows-latest, ubuntu-latest]
include:
- name: Install Rust - os: ubuntu-latest
uses: actions-rs/toolchain@v1 sccache-path: /home/runner/.cache/sccache
with: - os: macos-latest
profile: minimal sccache-path: /Users/runner/Library/Caches/Mozilla.sccache
toolchain: nightly - os: windows-latest
override: true sccache-path: "C:\\Users\\runneradmin\\AppData\\Local\\Mozilla\\sccache"
components: rustfmt
- name: cargo fmt --check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
env: env:
RUSTFLAGS: -Dwarnings RUSTC_WRAPPER: sccache
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ matrix.sccache-path }}
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install Rust - name: Install sccache Ubuntu
if: matrix.os == 'ubuntu-latest'
env:
LINK: https://github.com/mozilla/sccache/releases/download
SCCACHE_VERSION: v0.2.15
run: |
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
mkdir -p $HOME/.local/bin
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
chmod +x $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install sccache Macos
if: matrix.os == 'macos-latest'
run: |
brew update
brew install sccache
- name: Install sccache Windows
if: matrix.os == 'windows-latest'
run: |
iwr -useb get.scoop.sh | iex
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
scoop install sccache
echo "C:\Users\runneradmin\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Rust Stable
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
components: clippy
- name: Check examples - name: Cache cargo registry
uses: actions-rs/cargo@v1 uses: actions/cache@v2
continue-on-error: false
with: with:
command: clippy path: |
args: --examples --all ~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check examples with all features on stable - name: Save sccache
uses: actions-rs/cargo@v1 uses: actions/cache@v2
continue-on-error: false
with: with:
command: clippy path: ${{ matrix.sccache-path }}
args: --examples --all-features --all key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-sccache-
- name: Check benchmarks on nightly - name: Start sccache server
uses: actions-rs/cargo@v1 run: |
with: sccache --start-server
command: clippy
args: --all-features --examples --all --benches
test-package:
name: Test Package
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust (${{ matrix.rust }})
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Install cargo-all-features - name: Install cargo-all-features
run: | run: |
@ -97,21 +102,138 @@ jobs:
cd package cd package
cargo test-all-features cargo test-all-features
codecov: - name: Print sccache stats
name: Code Coverage run: sccache --show-stats
runs-on: ubuntu-latest
- name: Stop sccache server
run: sccache --stop-server || true
test-package-macos_m1:
name: Test Package macOS M1
runs-on: macos-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: /Users/runner/Library/Caches/Mozilla.sccache
steps: steps:
- name: Xcode Select
uses: devbotsxyz/xcode-select@v1.1.0
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Install sccache
run: |
brew update
brew install sccache
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
profile: minimal profile: minimal
toolchain: nightly target: aarch64-apple-darwin
toolchain: stable
override: true override: true
components: rustfmt components: rustfmt
- name: Cache cargo registry
uses: actions/cache@v2
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: m1-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
m1-cargo-
- name: Save sccache
uses: actions/cache@v2
continue-on-error: false
with:
path: /Users/runner/Library/Caches/Mozilla.sccache
key: m1-sccache-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
m1-sccache-
- name: Start sccache server
run: |
sccache --start-server
- name: Install cargo-all-features
run: |
SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path) \
MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version) \
cargo install cargo-all-features
- name: Test
run: |
SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path) \
MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version) \
cd package && cargo test-all-features
- name: Print sccache stats
run: sccache --show-stats
- name: Stop sccache server
run: sccache --stop-server || true
codecov:
name: Code Coverage
runs-on: ubuntu-latest
env:
RUSTC_BOOTSTRAP: 1
RUSTC_WRAPPER: sccache
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: /home/runner/.cache/sccache
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install sccache Ubuntu
env:
LINK: https://github.com/mozilla/sccache/releases/download
SCCACHE_VERSION: v0.2.15
run: |
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
mkdir -p $HOME/.local/bin
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
chmod +x $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- name: Cache cargo registry
uses: actions/cache@v2
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: codecov-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
codecov-cargo-
- name: Save sccache
uses: actions/cache@v2
continue-on-error: false
with:
path: /Users/runner/Library/Caches/Mozilla.sccache
key: codecov-sccache-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
codecov-sccache-
- name: Start sccache server
run: |
sccache --start-server
- name: Test - name: Test
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
@ -142,3 +264,9 @@ jobs:
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
- name: Print sccache stats
run: sccache --show-stats
- name: Stop sccache server
run: sccache --stop-server || true

View File

@ -8,9 +8,9 @@ use_field_init_shorthand = true
use_try_shorthand = true use_try_shorthand = true
# Nightly configurations # Nightly configurations
imports_layout = "HorizontalVertical" # imports_layout = "HorizontalVertical"
license_template_path = ".resources/license_header" # license_template_path = ".resources/license_header"
imports_granularity = "Crate" # imports_granularity = "Crate"
overflow_delimited_expr = true # overflow_delimited_expr = true
reorder_impl_items = true # reorder_impl_items = true
version = "Two" # version = "Two"

77
Cargo.lock generated
View File

@ -88,9 +88,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]] [[package]]
name = "assert_cmd" name = "assert_cmd"
version = "1.0.7" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d20831bd004dda4c7c372c19cdabff369f794a95e955b3f13fe460e3e1ae95f" checksum = "c98233c6673d8601ab23e77eb38f999c51100d46c5703b17288c57fddf3a1ffe"
dependencies = [ dependencies = [
"bstr", "bstr",
"doc-comment", "doc-comment",
@ -281,7 +281,7 @@ version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a"
dependencies = [ dependencies = [
"rustc_version 0.4.0", "rustc_version",
] ]
[[package]] [[package]]
@ -1205,7 +1205,6 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"tendril", "tendril",
"thiserror",
"typed-arena", "typed-arena",
] ]
@ -1293,7 +1292,6 @@ dependencies = [
"leo-ast", "leo-ast",
"leo-errors", "leo-errors",
"leo-parser", "leo-parser",
"thiserror",
"tracing", "tracing",
] ]
@ -1346,7 +1344,6 @@ dependencies = [
"snarkvm-utilities", "snarkvm-utilities",
"structopt", "structopt",
"test_dir", "test_dir",
"thiserror",
"toml", "toml",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
@ -1402,7 +1399,6 @@ dependencies = [
"snarkvm-curves", "snarkvm-curves",
"snarkvm-dpc", "snarkvm-dpc",
"snarkvm-utilities", "snarkvm-utilities",
"thiserror",
] ]
[[package]] [[package]]
@ -2237,15 +2233,6 @@ version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49" checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49"
[[package]]
name = "rustc_version"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee"
dependencies = [
"semver 0.11.0",
]
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.4.0" version = "0.4.0"
@ -2365,9 +2352,9 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.126" version = "1.0.127"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@ -2384,9 +2371,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.126" version = "1.0.127"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc"
dependencies = [ dependencies = [
"proc-macro2 1.0.27", "proc-macro2 1.0.27",
"quote 1.0.9", "quote 1.0.9",
@ -2485,9 +2472,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]] [[package]]
name = "snarkvm-algorithms" name = "snarkvm-algorithms"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8bbefe6252ed85bb073f8ecbc402830e3d119b1aaadcea5a9c9e7a21a99cd2" checksum = "7ceaacc1e52860b05cef025f5f7eea8179ba1327c5203008e938ba3aa50cd676"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bitvec", "bitvec",
@ -2513,14 +2500,14 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-curves" name = "snarkvm-curves"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62fdf07998a6e88fce7a8139e8282fb6b2702e49624b6d7e10a5cc1c9f014264" checksum = "7cb586a9383563b62120e788f8d9200cfcd5a5b610c2723403a72e6b4cc7ee71"
dependencies = [ dependencies = [
"derivative", "derivative",
"rand 0.8.4", "rand 0.8.4",
"rand_xorshift", "rand_xorshift",
"rustc_version 0.3.3", "rustc_version",
"serde", "serde",
"snarkvm-fields", "snarkvm-fields",
"snarkvm-utilities", "snarkvm-utilities",
@ -2529,9 +2516,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-derives" name = "snarkvm-derives"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d42f4d5abda149130149ce3865aef23d380dfcdd97fea7f75fd79b0aee369b29" checksum = "ec9f9134f9b06f279312d39a41c23fcc9ab29e987e74fc1e97a0945d1d169ff0"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro-error", "proc-macro-error",
@ -2542,9 +2529,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-dpc" name = "snarkvm-dpc"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af8dd1b815a1101c4014c17cbdffadecb1032e8662fdf5fd4bd67a3c149d8449" checksum = "acfc9ca513d8772a2b4f2e2596751bb427fc2a4c1942b4db79f54f15a41aa448"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base58", "base58",
@ -2574,9 +2561,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-fields" name = "snarkvm-fields"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ecd058b3608140610276be1eb1139a032a1bb171969b3ad70550c471d3ae503" checksum = "8a0717dbbf3e92e12084c913e53b21534270d2d00584a4344453af1c66952bee"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -2590,9 +2577,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-gadgets" name = "snarkvm-gadgets"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b462bb5e5ac219eafd1a828c73c181e7b23692ade5c49fd72d71bfe4250a6b1" checksum = "856e8e5aeaf1b5eccb1726bef4878ab4445977337cc35f63fc9172afee80d716"
dependencies = [ dependencies = [
"derivative", "derivative",
"digest 0.9.0", "digest 0.9.0",
@ -2610,9 +2597,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-marlin" name = "snarkvm-marlin"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e5b1bb7923a757053c0a544072ec6b298585f83c9f4a3ae777ca048bb6e5589" checksum = "9f426c842d30a47192a18aedcd84f5a892c0e491eca1e953899ab3363b7a9d14"
dependencies = [ dependencies = [
"blake2", "blake2",
"derivative", "derivative",
@ -2634,9 +2621,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-parameters" name = "snarkvm-parameters"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14356edda788a3e52ac6e809e6fdbfd5cf7558249bf6051525843b045a73d12a" checksum = "7da1fcd3d64f7480bbcfe2dfa86600d4d993a4d6fce006b99ea1b5edbd940df7"
dependencies = [ dependencies = [
"curl", "curl",
"hex", "hex",
@ -2647,9 +2634,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-polycommit" name = "snarkvm-polycommit"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28fac50de72680316fe57fbbbde2874ae28de7191a3f23ff9e541119951ddaa8" checksum = "513d200b3ec60bc9e5dd40293ac604781c1e0dbb383a3092146e06e37e440aab"
dependencies = [ dependencies = [
"derivative", "derivative",
"digest 0.9.0", "digest 0.9.0",
@ -2666,15 +2653,15 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-profiler" name = "snarkvm-profiler"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ebfa546f0376a1348b857a9defdb3f4505a0420d82f8caa2b0cebbe197245fa" checksum = "bc70acae38d1827eb81d9888791517cc5105b49c23c7b567f7c284145eb10c63"
[[package]] [[package]]
name = "snarkvm-r1cs" name = "snarkvm-r1cs"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aca9bb7105244ebc91f964b11a1ae63f173a77181307d1fa94f04e15dbde137" checksum = "749b0a504b8421b5d399893834bb0f9d1acf5c43769412b5c826381998c8a1e4"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"fxhash", "fxhash",
@ -2687,9 +2674,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-utilities" name = "snarkvm-utilities"
version = "0.7.5" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15b7ecf6a7afdd60a45cbd5ffab75185c296d8a4bf5eb20f3912384b1d4027c2" checksum = "1cc0611d450dfd4e9ad305dd343c0420430f83c73cdb79f6e6e184848dc3e2ee"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",

View File

@ -79,22 +79,22 @@ path = "./synthesizer"
version = "1.5.3" version = "1.5.3"
[dependencies.snarkvm-algorithms] [dependencies.snarkvm-algorithms]
version = "0.7.4" version = "0.7.6"
[dependencies.snarkvm-curves] [dependencies.snarkvm-curves]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.snarkvm-gadgets] [dependencies.snarkvm-gadgets]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.snarkvm-r1cs] [dependencies.snarkvm-r1cs]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.snarkvm-utilities] [dependencies.snarkvm-utilities]
version = "0.7.4" version = "0.7.6"
[dependencies.structopt] [dependencies.structopt]
version = "0.3" version = "0.3"
@ -144,9 +144,6 @@ features = [ "derive" ]
[dependencies.serde_json] [dependencies.serde_json]
version = "1.0" version = "1.0"
[dependencies.thiserror]
version = "1.0"
[dependencies.toml] [dependencies.toml]
version = "0.5" version = "0.5"
@ -167,7 +164,7 @@ version = "0.12.1"
version = "0.11.2" version = "0.11.2"
[dev-dependencies.assert_cmd] [dev-dependencies.assert_cmd]
version = "1.0.7" version = "1.0.8"
[dev-dependencies.test_dir] [dev-dependencies.test_dir]
version = "0.1.0" version = "0.1.0"

View File

@ -26,9 +26,6 @@ version = "1.0"
[dependencies.indexmap] [dependencies.indexmap]
version = "1.7" version = "1.7"
[dependencies.thiserror]
version = "1.0"
[dependencies.leo-ast] [dependencies.leo-ast]
version = "1.5.3" version = "1.5.3"
path = "../ast" path = "../ast"

View File

@ -15,17 +15,8 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
CircuitMember, CircuitMember, ConstValue, Expression, ExpressionNode, FromAst, Function, FunctionQualifier, Node, PartialType,
ConstValue, Scope, Type,
Expression,
ExpressionNode,
FromAst,
Function,
FunctionQualifier,
Node,
PartialType,
Scope,
Type,
}; };
pub use leo_ast::{BinaryOperation, Node as AstNode}; pub use leo_ast::{BinaryOperation, Node as AstNode};
use leo_errors::{AsgError, Result, Span}; use leo_errors::{AsgError, Result, Span};

View File

@ -15,17 +15,7 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
Circuit, Circuit, CircuitMember, ConstValue, Expression, ExpressionNode, FromAst, Identifier, Node, PartialType, Scope, Type,
CircuitMember,
ConstValue,
Expression,
ExpressionNode,
FromAst,
Identifier,
Node,
PartialType,
Scope,
Type,
}; };
use leo_errors::{AsgError, Result, Span}; use leo_errors::{AsgError, Result, Span};

View File

@ -15,17 +15,7 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
Circuit, Circuit, CircuitMember, ConstValue, Expression, ExpressionNode, FromAst, Identifier, Node, PartialType, Scope, Type,
CircuitMember,
ConstValue,
Expression,
ExpressionNode,
FromAst,
Identifier,
Node,
PartialType,
Scope,
Type,
}; };
use leo_errors::{AsgError, Result, Span}; use leo_errors::{AsgError, Result, Span};

View File

@ -15,17 +15,7 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
CharValue, CharValue, ConstInt, ConstValue, Expression, ExpressionNode, FromAst, GroupValue, Node, PartialType, Scope, Type,
ConstInt,
ConstValue,
Expression,
ExpressionNode,
FromAst,
GroupValue,
Node,
PartialType,
Scope,
Type,
}; };
use leo_errors::{AsgError, Result, Span}; use leo_errors::{AsgError, Result, Span};
@ -150,9 +140,7 @@ impl<'a> FromAst<'a, leo_ast::ValueExpression> for Constant<'a> {
span: Some(value.span().clone()), span: Some(value.span().clone()),
value: ConstValue::Group(match &**value { value: ConstValue::Group(match &**value {
leo_ast::GroupValue::Single(value, _) => GroupValue::Single(value.clone()), leo_ast::GroupValue::Single(value, _) => GroupValue::Single(value.clone()),
leo_ast::GroupValue::Tuple(tuple) => { leo_ast::GroupValue::Tuple(leo_ast::GroupTuple { x, y, .. }) => {
let x = &tuple.x;
let y = &tuple.y;
GroupValue::Tuple(x.into(), y.into()) GroupValue::Tuple(x.into(), y.into())
} }
}), }),
@ -234,11 +222,11 @@ impl<'a> Into<leo_ast::ValueExpression> for &Constant<'a> {
GroupValue::Single(single) => { GroupValue::Single(single) => {
leo_ast::GroupValue::Single(single.clone(), self.span.clone().unwrap_or_default()) leo_ast::GroupValue::Single(single.clone(), self.span.clone().unwrap_or_default())
} }
GroupValue::Tuple(left, right) => leo_ast::GroupValue::Tuple(Box::new(leo_ast::GroupTuple { GroupValue::Tuple(left, right) => leo_ast::GroupValue::Tuple(leo_ast::GroupTuple {
x: left.into(), x: left.into(),
y: right.into(), y: right.into(),
span: self.span.clone().unwrap_or_default(), span: self.span.clone().unwrap_or_default(),
})), }),
})), })),
ConstValue::Int(int) => leo_ast::ValueExpression::Integer( ConstValue::Int(int) => leo_ast::ValueExpression::Integer(
int.get_int_type(), int.get_int_type(),

View File

@ -15,18 +15,8 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
ConstValue, ConstValue, Constant, DefinitionStatement, Expression, ExpressionNode, FromAst, Node, PartialType, Scope,
Constant, Statement, Type, Variable,
DefinitionStatement,
Expression,
ExpressionNode,
FromAst,
Node,
PartialType,
Scope,
Statement,
Type,
Variable,
}; };
use leo_errors::{AsgError, Result, Span}; use leo_errors::{AsgError, Result, Span};

View File

@ -150,7 +150,7 @@ impl<'a> Into<leo_ast::Circuit> for &Circuit<'a> {
CircuitMember::Variable(type_) => { CircuitMember::Variable(type_) => {
leo_ast::CircuitMember::CircuitVariable(Identifier::new((&**name).into()), type_.into()) leo_ast::CircuitMember::CircuitVariable(Identifier::new((&**name).into()), type_.into())
} }
CircuitMember::Function(func) => leo_ast::CircuitMember::CircuitFunction(Box::new((*func).into())), CircuitMember::Function(func) => leo_ast::CircuitMember::CircuitFunction((*func).into()),
}) })
.collect(); .collect();
leo_ast::Circuit { leo_ast::Circuit {

View File

@ -15,16 +15,7 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
BlockStatement, BlockStatement, Circuit, FromAst, Identifier, MonoidalDirector, ReturnPathReducer, Scope, Statement, Type, Variable,
Circuit,
FromAst,
Identifier,
MonoidalDirector,
ReturnPathReducer,
Scope,
Statement,
Type,
Variable,
}; };
use indexmap::IndexMap; use indexmap::IndexMap;
pub use leo_ast::Annotation; pub use leo_ast::Annotation;
@ -177,13 +168,13 @@ impl<'a> Into<leo_ast::Function> for &Function<'a> {
.iter() .iter()
.map(|(_, variable)| { .map(|(_, variable)| {
let variable = variable.get().borrow(); let variable = variable.get().borrow();
leo_ast::FunctionInput::Variable(Box::new(leo_ast::FunctionInputVariable { leo_ast::FunctionInput::Variable(leo_ast::FunctionInputVariable {
identifier: variable.name.clone(), identifier: variable.name.clone(),
mutable: variable.mutable, mutable: variable.mutable,
const_: variable.const_, const_: variable.const_,
type_: (&variable.type_).into(), type_: (&variable.type_).into(),
span: Span::default(), span: Span::default(),
})) })
}) })
.collect(); .collect();
let (body, span) = match self.body.get() { let (body, span) = match self.body.get() {

View File

@ -15,20 +15,8 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
CircuitMember, CircuitMember, ConstInt, ConstValue, Expression, ExpressionNode, FromAst, Identifier, IntegerType, Node,
ConstInt, PartialType, Scope, Statement, Type, Variable,
ConstValue,
Expression,
ExpressionNode,
FromAst,
Identifier,
IntegerType,
Node,
PartialType,
Scope,
Statement,
Type,
Variable,
}; };
pub use leo_ast::AssignOperation; pub use leo_ast::AssignOperation;
use leo_ast::AssigneeAccess as AstAssigneeAccess; use leo_ast::AssigneeAccess as AstAssigneeAccess;

View File

@ -32,12 +32,15 @@ impl<'a> DefinitionStatement<'a> {
self.variables self.variables
.iter() .iter()
.map(|variable| { .map(|variable| {
(variable.borrow().name.name.to_string(), DefinitionStatement { (
variable.borrow().name.name.to_string(),
DefinitionStatement {
parent: self.parent.clone(), parent: self.parent.clone(),
span: self.span.clone(), span: self.span.clone(),
variables: vec![variable], variables: vec![variable],
value: self.value.clone(), value: self.value.clone(),
}) },
)
}) })
.collect() .collect()
} }

View File

@ -24,7 +24,7 @@ pub enum CircuitMember {
// (variable_name, variable_type) // (variable_name, variable_type)
CircuitVariable(Identifier, Type), CircuitVariable(Identifier, Type),
// (function) // (function)
CircuitFunction(Box<Function>), CircuitFunction(Function),
} }
impl fmt::Display for CircuitMember { impl fmt::Display for CircuitMember {

View File

@ -21,13 +21,9 @@ use tendril::StrTendril;
use crate::Node; use crate::Node;
use serde::{ use serde::{
de::{ de::{
Visitor, Visitor, {self},
{self},
}, },
Deserialize, Deserialize, Deserializer, Serialize, Serializer,
Deserializer,
Serialize,
Serializer,
}; };
use std::{ use std::{
collections::BTreeMap, collections::BTreeMap,

View File

@ -15,13 +15,7 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
ArrayDimensions, ArrayDimensions, CircuitImpliedVariableDefinition, GroupValue, Identifier, IntegerType, Node, PositiveNumber,
CircuitImpliedVariableDefinition,
GroupValue,
Identifier,
IntegerType,
Node,
PositiveNumber,
SpreadOrExpression, SpreadOrExpression,
}; };

View File

@ -25,8 +25,8 @@ use std::fmt;
pub enum FunctionInput { pub enum FunctionInput {
SelfKeyword(SelfKeyword), SelfKeyword(SelfKeyword),
ConstSelfKeyword(ConstSelfKeyword), ConstSelfKeyword(ConstSelfKeyword),
MutSelfKeyword(Box<MutSelfKeyword>), MutSelfKeyword(MutSelfKeyword),
Variable(Box<FunctionInputVariable>), Variable(FunctionInputVariable),
} }
impl FunctionInput { impl FunctionInput {

View File

@ -16,11 +16,8 @@
use leo_errors::Span; use leo_errors::Span;
use leo_input::values::{ use leo_input::values::{
GroupCoordinate as InputGroupCoordinate, GroupCoordinate as InputGroupCoordinate, Inferred as InputInferred, NumberValue as InputNumberValue,
Inferred as InputInferred, SignHigh as InputSignHigh, SignLow as InputSignLow,
NumberValue as InputNumberValue,
SignHigh as InputSignHigh,
SignLow as InputSignLow,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -17,9 +17,7 @@
use crate::groups::GroupCoordinate; use crate::groups::GroupCoordinate;
use leo_errors::Span; use leo_errors::Span;
use leo_input::values::{ use leo_input::values::{
GroupRepresentation as InputGroupRepresentation, GroupRepresentation as InputGroupRepresentation, GroupTuple as InputGroupTuple, GroupValue as InputGroupValue,
GroupTuple as InputGroupTuple,
GroupValue as InputGroupValue,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -29,7 +27,7 @@ use tendril::StrTendril;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum GroupValue { pub enum GroupValue {
Single(#[serde(with = "crate::common::tendril_json")] StrTendril, Span), Single(#[serde(with = "crate::common::tendril_json")] StrTendril, Span),
Tuple(Box<GroupTuple>), Tuple(GroupTuple),
} }
impl GroupValue { impl GroupValue {
@ -54,7 +52,7 @@ impl<'ast> From<InputGroupValue<'ast>> for GroupValue {
match ast_group.value { match ast_group.value {
InputGroupRepresentation::Single(number) => GroupValue::Single(number.to_string().into(), span), InputGroupRepresentation::Single(number) => GroupValue::Single(number.to_string().into(), span),
InputGroupRepresentation::Tuple(tuple) => GroupValue::Tuple(Box::new(GroupTuple::from(tuple))), InputGroupRepresentation::Tuple(tuple) => GroupValue::Tuple(GroupTuple::from(tuple)),
} }
} }
} }

View File

@ -24,7 +24,7 @@ use std::fmt;
pub enum PackageAccess { pub enum PackageAccess {
Star { span: Span }, Star { span: Span },
SubPackage(Box<Package>), SubPackage(Box<Package>),
Symbol(Box<ImportSymbol>), Symbol(ImportSymbol),
Multiple(Packages), Multiple(Packages),
} }

View File

@ -21,15 +21,8 @@ use leo_input::{
expressions::{ArrayInitializerExpression, ArrayInlineExpression, Expression, StringExpression, TupleExpression}, expressions::{ArrayInitializerExpression, ArrayInlineExpression, Expression, StringExpression, TupleExpression},
types::{ArrayType, CharType, DataType, IntegerType, TupleType, Type}, types::{ArrayType, CharType, DataType, IntegerType, TupleType, Type},
values::{ values::{
Address, Address, AddressValue, BooleanValue, CharValue as InputCharValue, FieldValue, GroupValue as InputGroupValue,
AddressValue, IntegerValue, NumberValue, Value,
BooleanValue,
CharValue as InputCharValue,
FieldValue,
GroupValue as InputGroupValue,
IntegerValue,
NumberValue,
Value,
}, },
}; };
use pest::Span; use pest::Span;
@ -42,7 +35,7 @@ pub enum InputValue {
Boolean(bool), Boolean(bool),
Char(CharValue), Char(CharValue),
Field(String), Field(String),
Group(Box<GroupValue>), Group(GroupValue),
Integer(IntegerType, String), Integer(IntegerType, String),
Array(Vec<InputValue>), Array(Vec<InputValue>),
Tuple(Vec<InputValue>), Tuple(Vec<InputValue>),
@ -80,7 +73,7 @@ impl InputValue {
} }
fn from_group(group: InputGroupValue) -> Self { fn from_group(group: InputGroupValue) -> Self {
InputValue::Group(Box::new(GroupValue::from(group))) InputValue::Group(GroupValue::from(group))
} }
fn from_field(field: FieldValue) -> Self { fn from_field(field: FieldValue) -> Self {

View File

@ -40,7 +40,11 @@ impl PublicState {
} }
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
if self.state.is_present() { 1usize } else { 0usize } if self.state.is_present() {
1usize
} else {
0usize
}
} }
/// Parse all input variables included in a file and store them in `self`. /// Parse all input variables included in a file and store them in `self`.

View File

@ -441,14 +441,14 @@ impl Canonicalizer {
output = Some(Type::Circuit(self.circuit_name.as_ref().unwrap().clone())); output = Some(Type::Circuit(self.circuit_name.as_ref().unwrap().clone()));
} }
return CircuitMember::CircuitFunction(Box::new(Function { return CircuitMember::CircuitFunction(Function {
annotations: function.annotations.clone(), annotations: function.annotations.clone(),
identifier: function.identifier.clone(), identifier: function.identifier.clone(),
input, input,
output, output,
block, block,
span: function.span.clone(), span: function.span.clone(),
})); });
} }
} }

View File

@ -92,7 +92,7 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
pub fn reduce_group_value(&mut self, group_value: &GroupValue) -> Result<GroupValue> { pub fn reduce_group_value(&mut self, group_value: &GroupValue) -> Result<GroupValue> {
let new = match group_value { let new = match group_value {
GroupValue::Tuple(group_tuple) => GroupValue::Tuple(Box::new(self.reduce_group_tuple(group_tuple)?)), GroupValue::Tuple(group_tuple) => GroupValue::Tuple(self.reduce_group_tuple(group_tuple)?),
_ => group_value.clone(), _ => group_value.clone(),
}; };
@ -454,7 +454,7 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
pub fn reduce_function_input(&mut self, input: &FunctionInput) -> Result<FunctionInput> { pub fn reduce_function_input(&mut self, input: &FunctionInput) -> Result<FunctionInput> {
let new = match input { let new = match input {
FunctionInput::Variable(function_input_variable) => { FunctionInput::Variable(function_input_variable) => {
FunctionInput::Variable(Box::new(self.reduce_function_input_variable(function_input_variable)?)) FunctionInput::Variable(self.reduce_function_input_variable(function_input_variable)?)
} }
_ => input.clone(), _ => input.clone(),
}; };
@ -491,9 +491,7 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
self.reduce_identifier(identifier)?, self.reduce_identifier(identifier)?,
self.reduce_type(type_, &identifier.span)?, self.reduce_type(type_, &identifier.span)?,
), ),
CircuitMember::CircuitFunction(function) => { CircuitMember::CircuitFunction(function) => CircuitMember::CircuitFunction(self.reduce_function(function)?),
CircuitMember::CircuitFunction(Box::new(self.reduce_function(function)?))
}
}; };
self.reducer.reduce_circuit_member(circuit_member, new) self.reducer.reduce_circuit_member(circuit_member, new)

View File

@ -15,8 +15,7 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use leo_input::types::{ use leo_input::types::{
IntegerType as InputIntegerType, IntegerType as InputIntegerType, SignedIntegerType as InputSignedIntegerType,
SignedIntegerType as InputSignedIntegerType,
UnsignedIntegerType as InputUnsignedIntegerType, UnsignedIntegerType as InputUnsignedIntegerType,
}; };

View File

@ -16,10 +16,7 @@
use crate::{ArrayDimensions, Identifier, IntegerType}; use crate::{ArrayDimensions, Identifier, IntegerType};
use leo_input::types::{ use leo_input::types::{
ArrayType as InputArrayType, ArrayType as InputArrayType, DataType as InputDataType, TupleType as InputTupleType, Type as InputType,
DataType as InputDataType,
TupleType as InputTupleType,
Type as InputType,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -61,28 +61,28 @@ version = "1.5.3"
version = "0.4" version = "0.4"
[dependencies.snarkvm-curves] [dependencies.snarkvm-curves]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.snarkvm-fields] [dependencies.snarkvm-fields]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.snarkvm-dpc] [dependencies.snarkvm-dpc]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.snarkvm-gadgets] [dependencies.snarkvm-gadgets]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
features = [ "curves" ] features = [ "curves" ]
[dependencies.snarkvm-r1cs] [dependencies.snarkvm-r1cs]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.snarkvm-utilities] [dependencies.snarkvm-utilities]
version = "0.7.4" version = "0.7.6"
[dependencies.bincode] [dependencies.bincode]
version = "1.3" version = "1.3"
@ -120,7 +120,7 @@ version = "0.3"
default-features = false default-features = false
[dev-dependencies.snarkvm-algorithms] [dev-dependencies.snarkvm-algorithms]
version = "0.7.4" version = "0.7.6"
default-features = false default-features = false
[dev-dependencies.tempfile] [dev-dependencies.tempfile]

View File

@ -17,12 +17,7 @@
//! Compiles a Leo program from a file path. //! Compiles a Leo program from a file path.
use crate::{ use crate::{
constraints::{generate_constraints, generate_test_constraints}, constraints::{generate_constraints, generate_test_constraints},
AstSnapshotOptions, AstSnapshotOptions, CompilerOptions, GroupType, Output, OutputFile, TypeInferencePhase,
CompilerOptions,
GroupType,
Output,
OutputFile,
TypeInferencePhase,
}; };
pub use leo_asg::{new_context, AsgContext as Context, AsgContext}; pub use leo_asg::{new_context, AsgContext as Context, AsgContext};
use leo_asg::{Asg, AsgPass, Program as AsgProgram}; use leo_asg::{Asg, AsgPass, Program as AsgProgram};

View File

@ -0,0 +1,167 @@
// Copyright (C) 2019-2021 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::errors::{
AddressError, BooleanError, CharError, FieldError, FunctionError, GroupError, IntegerError, ValueError,
};
use leo_ast::{FormattedError, Identifier, LeoError, Span};
use snarkvm_r1cs::SynthesisError;
#[derive(Debug, Error)]
pub enum ExpressionError {
#[error("{}", _0)]
AddressError(#[from] AddressError),
#[error("{}", _0)]
BooleanError(#[from] BooleanError),
#[error("{}", _0)]
CharError(#[from] CharError),
#[error("{}", _0)]
Error(#[from] FormattedError),
#[error("{}", _0)]
FieldError(#[from] FieldError),
#[error("{}", _0)]
FunctionError(#[from] Box<FunctionError>),
#[error("{}", _0)]
GroupError(#[from] GroupError),
#[error("{}", _0)]
IntegerError(#[from] IntegerError),
#[error("{}", _0)]
ValueError(#[from] ValueError),
}
impl LeoError for ExpressionError {}
impl ExpressionError {
fn new_from_span(message: String, span: &Span) -> Self {
ExpressionError::Error(FormattedError::new_from_span(message, span))
}
pub fn cannot_enforce(operation: String, error: SynthesisError, span: &Span) -> Self {
let message = format!(
"the gadget operation `{}` failed due to synthesis error `{:?}`",
operation, error,
);
Self::new_from_span(message, span)
}
pub fn cannot_evaluate(operation: String, span: &Span) -> Self {
let message = format!("Mismatched types found for operation `{}`", operation);
Self::new_from_span(message, span)
}
pub fn array_length_out_of_bounds(span: &Span) -> Self {
let message = "array length cannot be >= 2^32".to_string();
Self::new_from_span(message, span)
}
pub fn array_index_out_of_legal_bounds(span: &Span) -> Self {
let message = "array index cannot be >= 2^32".to_string();
Self::new_from_span(message, span)
}
pub fn conditional_boolean(actual: String, span: &Span) -> Self {
let message = format!("if, else conditional must resolve to a boolean, found `{}`", actual);
Self::new_from_span(message, span)
}
pub fn expected_circuit_member(expected: String, span: &Span) -> Self {
let message = format!("expected circuit member `{}`, not found", expected);
Self::new_from_span(message, span)
}
pub fn incompatible_types(operation: String, span: &Span) -> Self {
let message = format!("no implementation for `{}`", operation);
Self::new_from_span(message, span)
}
pub fn tuple_index_out_of_bounds(index: usize, span: &Span) -> Self {
let message = format!("cannot access index {} of tuple out of bounds", index);
Self::new_from_span(message, span)
}
pub fn array_index_out_of_bounds(index: usize, span: &Span) -> Self {
let message = format!("cannot access index {} of array out of bounds", index);
Self::new_from_span(message, span)
}
pub fn array_invalid_slice_length(span: &Span) -> Self {
let message = "illegal length of slice".to_string();
Self::new_from_span(message, span)
}
pub fn invalid_index(actual: String, span: &Span) -> Self {
let message = format!("index must resolve to an integer, found `{}`", actual);
Self::new_from_span(message, span)
}
pub fn invalid_length(expected: usize, actual: usize, span: &Span) -> Self {
let message = format!("expected array length {}, found one with length {}", expected, actual);
Self::new_from_span(message, span)
}
pub fn invalid_static_access(member: String, span: &Span) -> Self {
let message = format!("static member `{}` must be accessed using `::` syntax", member);
Self::new_from_span(message, span)
}
pub fn undefined_array(actual: String, span: &Span) -> Self {
let message = format!("array `{}` must be declared before it is used in an expression", actual);
Self::new_from_span(message, span)
}
pub fn undefined_circuit(actual: String, span: &Span) -> Self {
let message = format!(
"circuit `{}` must be declared before it is used in an expression",
actual
);
Self::new_from_span(message, span)
}
pub fn undefined_identifier(identifier: Identifier) -> Self {
let message = format!("Cannot find value `{}` in this scope", identifier.name);
Self::new_from_span(message, &identifier.span)
}
pub fn undefined_member_access(circuit: String, member: String, span: &Span) -> Self {
let message = format!("Circuit `{}` has no member `{}`", circuit, member);
Self::new_from_span(message, span)
}
}

View File

@ -0,0 +1,138 @@
// Copyright (C) 2019-2021 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::errors::{
AddressError, BooleanError, CharError, ExpressionError, FieldError, GroupError, IntegerError, OutputBytesError,
StatementError, ValueError,
};
use leo_asg::AsgConvertError;
use leo_ast::{FormattedError, LeoError, Span};
#[derive(Debug, Error)]
pub enum FunctionError {
#[error("{}", _0)]
AddressError(#[from] AddressError),
#[error("{}", _0)]
BooleanError(#[from] BooleanError),
#[error("{}", _0)]
CharError(#[from] CharError),
#[error("{}", _0)]
ExpressionError(#[from] ExpressionError),
#[error("{}", _0)]
Error(#[from] FormattedError),
#[error("{}", _0)]
FieldError(#[from] FieldError),
#[error("{}", _0)]
GroupError(#[from] GroupError),
#[error("{}", _0)]
IntegerError(#[from] IntegerError),
#[error("{}", _0)]
OutputStringError(#[from] OutputBytesError),
#[error("{}", _0)]
StatementError(#[from] StatementError),
#[error("{}", _0)]
ValueError(#[from] ValueError),
#[error("{}", _0)]
ImportASGError(#[from] AsgConvertError),
}
impl LeoError for FunctionError {}
impl FunctionError {
fn new_from_span(message: String, span: &Span) -> Self {
FunctionError::Error(FormattedError::new_from_span(message, span))
}
pub fn input_type_mismatch(expected: String, actual: String, variable: String, span: &Span) -> Self {
let message = format!(
"Expected input variable `{}` to be type `{}`, found type `{}`",
variable, expected, actual
);
Self::new_from_span(message, span)
}
pub fn expected_const_input(variable: String, span: &Span) -> Self {
let message = format!(
"Expected input variable `{}` to be constant. Move input variable `{}` to [constants] section of input file",
variable, variable
);
Self::new_from_span(message, span)
}
pub fn expected_non_const_input(variable: String, span: &Span) -> Self {
let message = format!(
"Expected input variable `{}` to be non-constant. Move input variable `{}` to [main] section of input file",
variable, variable
);
Self::new_from_span(message, span)
}
pub fn invalid_array(actual: String, span: &Span) -> Self {
let message = format!("Expected function input array, found `{}`", actual);
Self::new_from_span(message, span)
}
pub fn invalid_input_array_dimensions(expected: usize, actual: usize, span: &Span) -> Self {
let message = format!(
"Input array dimensions mismatch expected {}, found array dimensions {}",
expected, actual
);
Self::new_from_span(message, span)
}
pub fn tuple_size_mismatch(expected: usize, actual: usize, span: &Span) -> Self {
let message = format!(
"Input tuple size mismatch expected {}, found tuple with length {}",
expected, actual
);
Self::new_from_span(message, span)
}
pub fn invalid_tuple(actual: String, span: &Span) -> Self {
let message = format!("Expected function input tuple, found `{}`", actual);
Self::new_from_span(message, span)
}
pub fn input_not_found(expected: String, span: &Span) -> Self {
let message = format!("main function input {} not found", expected);
Self::new_from_span(message, span)
}
pub fn double_input_declaration(input_name: String, span: &Span) -> Self {
let message = format!("Input variable {} declared twice", input_name);
Self::new_from_span(message, span)
}
}

View File

@ -23,8 +23,7 @@ use crate::{
relational::*, relational::*,
resolve_core_circuit, resolve_core_circuit,
value::{Address, Char, CharType, ConstrainedCircuitMember, ConstrainedValue, Integer}, value::{Address, Char, CharType, ConstrainedCircuitMember, ConstrainedValue, Integer},
FieldType, FieldType, GroupType,
GroupType,
}; };
use leo_asg::{expression::*, ConstValue, Expression, Node}; use leo_asg::{expression::*, ConstValue, Expression, Node};
use leo_errors::{Result, Span}; use leo_errors::{Result, Span};

View File

@ -20,16 +20,10 @@ use crate::{
address::Address, address::Address,
program::ConstrainedProgram, program::ConstrainedProgram,
value::{ value::{
boolean::input::bool_from_input, boolean::input::bool_from_input, char::char_from_input, field::input::field_from_input,
char::char_from_input, group::input::group_from_input, ConstrainedValue,
field::input::field_from_input,
group::input::group_from_input,
ConstrainedValue,
}, },
CharType, CharType, FieldType, GroupType, Integer,
FieldType,
GroupType,
Integer,
}; };
use leo_asg::{ConstInt, Type}; use leo_asg::{ConstInt, Type};
use leo_ast::{Char, InputValue}; use leo_ast::{Char, InputValue};
@ -100,9 +94,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> ConstrainedProgram<'a, F, G> {
(Type::Field, InputValue::Field(value)) => { (Type::Field, InputValue::Field(value)) => {
Ok(ConstrainedValue::Field(FieldType::constant(cs, value, span)?)) Ok(ConstrainedValue::Field(FieldType::constant(cs, value, span)?))
} }
(Type::Group, InputValue::Group(value)) => { (Type::Group, InputValue::Group(value)) => Ok(ConstrainedValue::Group(G::constant(&value.into(), span)?)),
Ok(ConstrainedValue::Group(G::constant(&(*value).into(), span)?))
}
(Type::Integer(integer_type), InputValue::Integer(input_type, value)) => { (Type::Integer(integer_type), InputValue::Integer(input_type, value)) => {
let parsed = ConstInt::parse(integer_type, &value, span)?; let parsed = ConstInt::parse(integer_type, &value, span)?;
let parsed_type = parsed.get_int_type(); let parsed_type = parsed.get_int_type();

View File

@ -20,16 +20,8 @@ use std::cell::Cell;
use crate::{program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use crate::{program::ConstrainedProgram, value::ConstrainedValue, GroupType};
use leo_asg::{ use leo_asg::{
ArrayAccessExpression, ArrayAccessExpression, ArrayRangeAccessExpression, AssignAccess, AssignOperation, AssignStatement,
ArrayRangeAccessExpression, CircuitAccessExpression, Expression, Node, TupleAccessExpression, Variable,
AssignAccess,
AssignOperation,
AssignStatement,
CircuitAccessExpression,
Expression,
Node,
TupleAccessExpression,
Variable,
}; };
use leo_errors::Result; use leo_errors::Result;

View File

@ -155,10 +155,13 @@ impl Output {
_ => value.to_string(), _ => value.to_string(),
}; };
registers.insert(name.to_string(), OutputRegister { registers.insert(
name.to_string(),
OutputRegister {
type_: register_type.to_string(), type_: register_type.to_string(),
value, value,
}); },
);
} }
Ok(Output { registers }) Ok(Output { registers })

View File

@ -21,8 +21,7 @@ use leo_errors::{CompilerError, Result};
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -18,83 +18,37 @@
use indexmap::IndexMap; use indexmap::IndexMap;
use leo_asg::{ use leo_asg::{
ArrayAccessExpression as AsgArrayAccessExpression, ArrayAccessExpression as AsgArrayAccessExpression, ArrayInitExpression as AsgArrayInitExpression,
ArrayInitExpression as AsgArrayInitExpression, ArrayInlineExpression as AsgArrayInlineExpression, ArrayRangeAccessExpression as AsgArrayRangeAccessExpression,
ArrayInlineExpression as AsgArrayInlineExpression, AssignAccess as AsgAssignAccess, AssignStatement as AsgAssignStatement, BinaryExpression as AsgBinaryExpression,
ArrayRangeAccessExpression as AsgArrayRangeAccessExpression, BlockStatement as AsgBlockStatement, CallExpression as AsgCallExpression, CastExpression as AsgCastExpression,
AssignAccess as AsgAssignAccess, CharValue as AsgCharValue, Circuit as AsgCircuit, CircuitAccessExpression as AsgCircuitAccessExpression,
AssignStatement as AsgAssignStatement, CircuitInitExpression as AsgCircuitInitExpression, CircuitMember as AsgCircuitMember,
BinaryExpression as AsgBinaryExpression, ConditionalStatement as AsgConditionalStatement, ConsoleFunction as AsgConsoleFunction,
BlockStatement as AsgBlockStatement, ConsoleStatement as AsgConsoleStatement, ConstValue, Constant as AsgConstant,
CallExpression as AsgCallExpression, DefinitionStatement as AsgDefinitionStatement, Expression as AsgExpression,
CastExpression as AsgCastExpression, ExpressionStatement as AsgExpressionStatement, Function as AsgFunction, GroupValue as AsgGroupValue,
CharValue as AsgCharValue, IterationStatement as AsgIterationStatement, ReturnStatement as AsgReturnStatement, Statement as AsgStatement,
Circuit as AsgCircuit, TernaryExpression as AsgTernaryExpression, TupleAccessExpression as AsgTupleAccessExpression,
CircuitAccessExpression as AsgCircuitAccessExpression, TupleInitExpression as AsgTupleInitExpression, Type as AsgType, UnaryExpression as AsgUnaryExpression,
CircuitInitExpression as AsgCircuitInitExpression,
CircuitMember as AsgCircuitMember,
ConditionalStatement as AsgConditionalStatement,
ConsoleFunction as AsgConsoleFunction,
ConsoleStatement as AsgConsoleStatement,
ConstValue,
Constant as AsgConstant,
DefinitionStatement as AsgDefinitionStatement,
Expression as AsgExpression,
ExpressionStatement as AsgExpressionStatement,
Function as AsgFunction,
GroupValue as AsgGroupValue,
IterationStatement as AsgIterationStatement,
ReturnStatement as AsgReturnStatement,
Statement as AsgStatement,
TernaryExpression as AsgTernaryExpression,
TupleAccessExpression as AsgTupleAccessExpression,
TupleInitExpression as AsgTupleInitExpression,
Type as AsgType,
UnaryExpression as AsgUnaryExpression,
VariableRef as AsgVariableRef, VariableRef as AsgVariableRef,
}; };
use leo_ast::{ use leo_ast::{
ArrayAccessExpression as AstArrayAccessExpression, ArrayAccessExpression as AstArrayAccessExpression, ArrayDimensions, ArrayInitExpression as AstArrayInitExpression,
ArrayDimensions, ArrayInlineExpression as AstArrayInlineExpression, ArrayRangeAccessExpression as AstArrayRangeAccessExpression,
ArrayInitExpression as AstArrayInitExpression, AssignStatement as AstAssignStatement, Assignee, AssigneeAccess as AstAssignAccess,
ArrayInlineExpression as AstArrayInlineExpression, BinaryExpression as AstBinaryExpression, Block as AstBlockStatement, CallExpression as AstCallExpression,
ArrayRangeAccessExpression as AstArrayRangeAccessExpression, CastExpression as AstCastExpression, Char, CharValue as AstCharValue, Circuit as AstCircuit,
AssignStatement as AstAssignStatement, CircuitImpliedVariableDefinition, CircuitInitExpression as AstCircuitInitExpression,
Assignee, CircuitMember as AstCircuitMember, CircuitMemberAccessExpression, CircuitStaticFunctionAccessExpression,
AssigneeAccess as AstAssignAccess, ConditionalStatement as AstConditionalStatement, ConsoleArgs as AstConsoleArgs,
BinaryExpression as AstBinaryExpression, ConsoleFunction as AstConsoleFunction, ConsoleStatement as AstConsoleStatement,
Block as AstBlockStatement, DefinitionStatement as AstDefinitionStatement, Expression as AstExpression,
CallExpression as AstCallExpression, ExpressionStatement as AstExpressionStatement, Function as AstFunction, GroupTuple, GroupValue as AstGroupValue,
CastExpression as AstCastExpression, IterationStatement as AstIterationStatement, PositiveNumber, ReconstructingReducer,
Char, ReturnStatement as AstReturnStatement, SpreadOrExpression, Statement as AstStatement,
CharValue as AstCharValue, TernaryExpression as AstTernaryExpression, TupleAccessExpression as AstTupleAccessExpression,
Circuit as AstCircuit, TupleInitExpression as AstTupleInitExpression, Type as AstType, UnaryExpression as AstUnaryExpression,
CircuitImpliedVariableDefinition,
CircuitInitExpression as AstCircuitInitExpression,
CircuitMember as AstCircuitMember,
CircuitMemberAccessExpression,
CircuitStaticFunctionAccessExpression,
ConditionalStatement as AstConditionalStatement,
ConsoleArgs as AstConsoleArgs,
ConsoleFunction as AstConsoleFunction,
ConsoleStatement as AstConsoleStatement,
DefinitionStatement as AstDefinitionStatement,
Expression as AstExpression,
ExpressionStatement as AstExpressionStatement,
Function as AstFunction,
GroupTuple,
GroupValue as AstGroupValue,
IterationStatement as AstIterationStatement,
PositiveNumber,
ReconstructingReducer,
ReturnStatement as AstReturnStatement,
SpreadOrExpression,
Statement as AstStatement,
TernaryExpression as AstTernaryExpression,
TupleAccessExpression as AstTupleAccessExpression,
TupleInitExpression as AstTupleInitExpression,
Type as AstType,
UnaryExpression as AstUnaryExpression,
ValueExpression, ValueExpression,
}; };
use leo_errors::{AstError, Result, Span}; use leo_errors::{AstError, Result, Span};
@ -399,11 +353,11 @@ impl<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
ConstValue::Group(group) => { ConstValue::Group(group) => {
let group_value = match group { let group_value = match group {
AsgGroupValue::Single(_) => AstGroupValue::Single(tendril.clone(), span.clone()), AsgGroupValue::Single(_) => AstGroupValue::Single(tendril.clone(), span.clone()),
AsgGroupValue::Tuple(x, y) => AstGroupValue::Tuple(Box::new(GroupTuple { AsgGroupValue::Tuple(x, y) => AstGroupValue::Tuple(GroupTuple {
x: x.into(), x: x.into(),
y: y.into(), y: y.into(),
span: span.clone(), span: span.clone(),
})), }),
}; };
new = ValueExpression::Group(Box::new(group_value)); new = ValueExpression::Group(Box::new(group_value));
} }
@ -732,7 +686,7 @@ impl<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
) )
} }
(AstCircuitMember::CircuitFunction(ast_function), AsgCircuitMember::Function(asg_function)) => { (AstCircuitMember::CircuitFunction(ast_function), AsgCircuitMember::Function(asg_function)) => {
AstCircuitMember::CircuitFunction(Box::new(self.reduce_function(ast_function, asg_function)?)) AstCircuitMember::CircuitFunction(self.reduce_function(ast_function, asg_function)?)
} }
_ => ast.clone(), _ => ast.clone(),
}; };

View File

@ -21,10 +21,7 @@ use leo_errors::{CompilerError, Result, Span};
use snarkvm_fields::PrimeField; use snarkvm_fields::PrimeField;
use snarkvm_gadgets::{ use snarkvm_gadgets::{
algorithms::prf::Blake2sGadget, algorithms::prf::Blake2sGadget, bits::ToBytesGadget, integers::uint::UInt8, traits::algorithms::PRFGadget,
bits::ToBytesGadget,
integers::uint::UInt8,
traits::algorithms::PRFGadget,
}; };
use snarkvm_r1cs::ConstraintSystem; use snarkvm_r1cs::ConstraintSystem;

View File

@ -96,7 +96,9 @@ impl<'a, F: PrimeField, G: GroupType<F>> ConstrainedProgram<'a, F, G> {
let mut target = self.get(variable.id).unwrap().clone(); let mut target = self.get(variable.id).unwrap().clone();
let accesses: Vec<_> = assignee.target_accesses.iter().rev().collect(); let accesses: Vec<_> = assignee.target_accesses.iter().rev().collect();
self.resolve_target_access(cs, ResolverContext { self.resolve_target_access(
cs,
ResolverContext {
input: vec![&mut target], input: vec![&mut target],
span, span,
target_value, target_value,
@ -104,7 +106,8 @@ impl<'a, F: PrimeField, G: GroupType<F>> ConstrainedProgram<'a, F, G> {
indicator, indicator,
operation: assignee.operation, operation: assignee.operation,
from_range: false, from_range: false,
})?; },
)?;
*self.get_mut(variable.id).unwrap() = target; *self.get_mut(variable.id).unwrap() = target;
Ok(()) Ok(())
} }

View File

@ -17,11 +17,7 @@
//! Methods to enforce constraints on statements in a compiled Leo program. //! Methods to enforce constraints on statements in a compiled Leo program.
use crate::{ use crate::{
program::ConstrainedProgram, program::ConstrainedProgram, value::ConstrainedValue, GroupType, IndicatorAndConstrainedValue, StatementResult,
value::ConstrainedValue,
GroupType,
IndicatorAndConstrainedValue,
StatementResult,
}; };
use leo_asg::ConditionalStatement; use leo_asg::ConditionalStatement;
use leo_errors::CompilerError; use leo_errors::CompilerError;

View File

@ -17,13 +17,8 @@
//! Enforces an iteration statement in a compiled Leo program. //! Enforces an iteration statement in a compiled Leo program.
use crate::{ use crate::{
program::ConstrainedProgram, program::ConstrainedProgram, value::ConstrainedValue, GroupType, IndicatorAndConstrainedValue, Integer,
value::ConstrainedValue, IntegerTrait, StatementResult,
GroupType,
IndicatorAndConstrainedValue,
Integer,
IntegerTrait,
StatementResult,
}; };
use leo_asg::IterationStatement; use leo_asg::IterationStatement;
use leo_errors::CompilerError; use leo_errors::CompilerError;

View File

@ -226,7 +226,11 @@ impl<F: PrimeField> ConditionalEqGadget<F> for Address {
} }
fn cond_select_helper(first: &Address, second: &Address, cond: bool) -> Address { fn cond_select_helper(first: &Address, second: &Address, cond: bool) -> Address {
if cond { first.clone() } else { second.clone() } if cond {
first.clone()
} else {
second.clone()
}
} }
impl<F: PrimeField> CondSelectGadget<F> for Address { impl<F: PrimeField> CondSelectGadget<F> for Address {

View File

@ -16,8 +16,7 @@
use crate::{ use crate::{
value::{field::input::allocate_field, ConstrainedValue}, value::{field::input::allocate_field, ConstrainedValue},
FieldType, FieldType, GroupType,
GroupType,
}; };
use leo_ast::InputValue; use leo_ast::InputValue;

View File

@ -58,9 +58,9 @@ pub(crate) fn group_from_input<'a, F: PrimeField, G: GroupType<F>, CS: Constrain
let group = allocate_group( let group = allocate_group(
cs, cs,
name, name,
option.map(|x| match *x { option.map(|x| match x {
leo_ast::GroupValue::Single(s, _) => GroupValue::Single(s), leo_ast::GroupValue::Single(s, _) => GroupValue::Single(s),
leo_ast::GroupValue::Tuple(tuple) => GroupValue::Tuple((&tuple.x).into(), (&tuple.y).into()), leo_ast::GroupValue::Tuple(leo_ast::GroupTuple { x, y, .. }) => GroupValue::Tuple((&x).into(), (&y).into()),
}), }),
span, span,
)?; )?;

View File

@ -21,8 +21,7 @@ use leo_errors::{CompilerError, Result, Span};
use snarkvm_curves::{ use snarkvm_curves::{
edwards_bls12::{EdwardsAffine, EdwardsParameters, Fq}, edwards_bls12::{EdwardsAffine, EdwardsParameters, Fq},
templates::twisted_edwards_extended::Affine, templates::twisted_edwards_extended::Affine,
AffineCurve, AffineCurve, TwistedEdwardsParameters,
TwistedEdwardsParameters,
}; };
use snarkvm_fields::{Fp256, One, Zero}; use snarkvm_fields::{Fp256, One, Zero};
use snarkvm_gadgets::{ use snarkvm_gadgets::{
@ -485,7 +484,11 @@ impl CondSelectGadget<Fq> for EdwardsGroupType {
second: &Self, second: &Self,
) -> Result<Self, SynthesisError> { ) -> Result<Self, SynthesisError> {
if let Boolean::Constant(cond) = *cond { if let Boolean::Constant(cond) = *cond {
if cond { Ok(first.clone()) } else { Ok(second.clone()) } if cond {
Ok(first.clone())
} else {
Ok(second.clone())
}
} else { } else {
let first_gadget = first.allocated(cs.ns(|| "first"))?; let first_gadget = first.allocated(cs.ns(|| "first"))?;
let second_gadget = second.allocated(cs.ns(|| "second"))?; let second_gadget = second.allocated(cs.ns(|| "second"))?;

View File

@ -17,13 +17,13 @@ include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ]
license = "GPL-3.0" license = "GPL-3.0"
edition = "2018" edition = "2018"
[dependencies]
color-backtrace = "0.5.1"
[dependencies.leo-input] [dependencies.leo-input]
path = "../input" path = "../input"
version = "1.5.3" version = "1.5.3"
[dependencies.color-backtrace]
version = "0.5.1"
[dependencies.derivative] [dependencies.derivative]
version = "2.2.0" version = "2.2.0"

View File

@ -25,6 +25,13 @@ create_errors!(
exit_code_mask: 7000i32, exit_code_mask: 7000i32,
error_code_prefix: "CLI", error_code_prefix: "CLI",
@backtraced
opt_args_error {
args: (error: impl ErrorArg),
msg: format!("opt arg error {}", error),
help: None,
}
@backtraced @backtraced
unidentified_api { unidentified_api {
args: (), args: (),

View File

@ -101,7 +101,6 @@ impl fmt::Display for BacktracedError {
let leo_backtrace = std::env::var("LEO_BACKTRACE").unwrap_or_default().trim().to_owned(); let leo_backtrace = std::env::var("LEO_BACKTRACE").unwrap_or_default().trim().to_owned();
match leo_backtrace.as_ref() { match leo_backtrace.as_ref() {
"1" => { "1" => {
dbg!("1");
let mut printer = BacktracePrinter::default(); let mut printer = BacktracePrinter::default();
printer = printer.lib_verbosity(Verbosity::Medium); printer = printer.lib_verbosity(Verbosity::Medium);
let trace = printer let trace = printer
@ -110,7 +109,6 @@ impl fmt::Display for BacktracedError {
write!(f, "{}", trace)?; write!(f, "{}", trace)?;
} }
"full" => { "full" => {
dbg!("full");
let mut printer = BacktracePrinter::default(); let mut printer = BacktracePrinter::default();
printer = printer.lib_verbosity(Verbosity::Full); printer = printer.lib_verbosity(Verbosity::Full);
let trace = printer let trace = printer

View File

@ -476,7 +476,7 @@ Line terminators form whitespace, along with spaces and horizontal tabs.
whitespace = space / horizontal-tab / newline whitespace = space / horizontal-tab / newline
``` ```
Go to: _[space](#user-content-space), [newline](#user-content-newline), [horizontal-tab](#user-content-horizontal-tab)_; Go to: _[horizontal-tab](#user-content-horizontal-tab), [newline](#user-content-newline), [space](#user-content-space)_;
There are two kinds of comments in Leo, as in other languages. There are two kinds of comments in Leo, as in other languages.
@ -511,7 +511,7 @@ rest-of-block-comment = "*" rest-of-block-comment-after-star
/ not-star rest-of-block-comment / not-star rest-of-block-comment
``` ```
Go to: _[not-star](#user-content-not-star), [rest-of-block-comment](#user-content-rest-of-block-comment), [rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star)_; Go to: _[rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star), [not-star](#user-content-not-star), [rest-of-block-comment](#user-content-rest-of-block-comment)_;
<a name="rest-of-block-comment-after-star"></a> <a name="rest-of-block-comment-after-star"></a>
@ -521,7 +521,7 @@ rest-of-block-comment-after-star = "/"
/ not-star-or-slash rest-of-block-comment / not-star-or-slash rest-of-block-comment
``` ```
Go to: _[rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star), [not-star-or-slash](#user-content-not-star-or-slash), [rest-of-block-comment](#user-content-rest-of-block-comment)_; Go to: _[not-star-or-slash](#user-content-not-star-or-slash), [rest-of-block-comment](#user-content-rest-of-block-comment), [rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star)_;
<a name="end-of-line-comment"></a> <a name="end-of-line-comment"></a>
@ -572,13 +572,7 @@ keyword = %s"address"
/ %s"u128" / %s"u128"
``` ```
The following rules define (ASCII) The following rules define (ASCII) letters.
digits and (uppercase and lowercase) letters.
<a name="digit"></a>
```abnf
digit = %x30-39 ; 0-9
```
<a name="uppercase-letter"></a> <a name="uppercase-letter"></a>
```abnf ```abnf
@ -595,12 +589,17 @@ lowercase-letter = %x61-7A ; a-z
letter = uppercase-letter / lowercase-letter letter = uppercase-letter / lowercase-letter
``` ```
Go to: _[lowercase-letter](#user-content-lowercase-letter), [uppercase-letter](#user-content-uppercase-letter)_; Go to: _[uppercase-letter](#user-content-uppercase-letter), [lowercase-letter](#user-content-lowercase-letter)_;
The following rules defines (ASCII) octal and hexadecimal digits. The following rules defines (ASCII) decimal, octal, and hexadecimal digits.
Note that the latter are case-insensitive. Note that the latter are case-insensitive.
<a name="decimal-digit"></a>
```abnf
decimal-digit = %x30-39 ; 0-9
```
<a name="octal-digit"></a> <a name="octal-digit"></a>
```abnf ```abnf
octal-digit = %x30-37 ; 0-7 octal-digit = %x30-37 ; 0-7
@ -608,13 +607,14 @@ octal-digit = %x30-37 ; 0-7
<a name="hexadecimal-digit"></a> <a name="hexadecimal-digit"></a>
```abnf ```abnf
hexadecimal-digit = digit / "a" / "b" / "c" / "d" / "e" / "f" hexadecimal-digit = decimal-digit / "a" / "b" / "c" / "d" / "e" / "f"
``` ```
Go to: _[digit](#user-content-digit)_; Go to: _[decimal-digit](#user-content-decimal-digit)_;
An identifier is a non-empty sequence of letters, digits, and underscores, An identifier is a non-empty sequence of
letters, (decimal) digits, and underscores,
starting with a letter. starting with a letter.
It must not be a keyword: this is an extra-grammatical requirement. It must not be a keyword: this is an extra-grammatical requirement.
It must also not be or start with `aleo1`, It must also not be or start with `aleo1`,
@ -623,7 +623,7 @@ this is another extra-grammatical requirement.
<a name="identifier"></a> <a name="identifier"></a>
```abnf ```abnf
identifier = letter *( letter / digit / "_" ) identifier = letter *( letter / decimal-digit / "_" )
; but not a keyword or a boolean literal or aleo1... ; but not a keyword or a boolean literal or aleo1...
``` ```
@ -631,14 +631,15 @@ Go to: _[letter](#user-content-letter)_;
A package name consists of one or more segments separated by single dashes, A package name consists of one or more segments separated by single dashes,
where each segment is a non-empty sequence of lowercase letters and digits. where each segment is a non-empty sequence of
lowercase letters and (decimal) digits.
Similarly to an identifier, a package name must not be a keyword Similarly to an identifier, a package name must not be a keyword
and must not be or start with `aleo1`. and must not be or start with `aleo1`.
<a name="package-name"></a> <a name="package-name"></a>
```abnf ```abnf
package-name = lowercase-letter *( lowercase-letter / digit ) package-name = lowercase-letter *( lowercase-letter / decimal-digit )
*( "-" 1*( lowercase-letter / digit ) ) *( "-" 1*( lowercase-letter / decimal-digit ) )
; but not a keyword or a boolean literal or aleo1... ; but not a keyword or a boolean literal or aleo1...
``` ```
@ -658,12 +659,12 @@ annotation-name = "@" identifier
Go to: _[identifier](#user-content-identifier)_; Go to: _[identifier](#user-content-identifier)_;
A natural (number) is a sequence of one or more digits. A natural (number) is a sequence of one or more decimal digits.
We allow leading zeros, e.g. `007`. We allow leading zeros, e.g. `007`.
<a name="natural"></a> <a name="natural"></a>
```abnf ```abnf
natural = 1*digit natural = 1*decimal-digit
``` ```
An integer (number) is either a natural or its negation. An integer (number) is either a natural or its negation.
@ -739,12 +740,12 @@ boolean-literal = %s"true" / %s"false"
``` ```
An address literal starts with `aleo1` An address literal starts with `aleo1`
and continues with exactly 58 lowercase letters and digits. and continues with exactly 58 lowercase letters and (decimal) digits.
Thus an address always consists of 63 characters. Thus an address always consists of 63 characters.
<a name="address-literal"></a> <a name="address-literal"></a>
```abnf ```abnf
address-literal = %s"aleo1" 58( lowercase-letter / digit ) address-literal = %s"aleo1" 58( lowercase-letter / decimal-digit )
``` ```
A character literal consists of an element surrounded by single quotes. A character literal consists of an element surrounded by single quotes.
@ -772,7 +773,7 @@ character-literal-element = not-single-quote-or-backslash
/ unicode-character-escape / unicode-character-escape
``` ```
Go to: _[unicode-character-escape](#user-content-unicode-character-escape), [simple-character-escape](#user-content-simple-character-escape), [not-single-quote-or-backslash](#user-content-not-single-quote-or-backslash), [ascii-character-escape](#user-content-ascii-character-escape)_; Go to: _[not-single-quote-or-backslash](#user-content-not-single-quote-or-backslash), [ascii-character-escape](#user-content-ascii-character-escape), [unicode-character-escape](#user-content-unicode-character-escape), [simple-character-escape](#user-content-simple-character-escape)_;
<a name="single-quote-escape"></a> <a name="single-quote-escape"></a>
@ -827,7 +828,7 @@ simple-character-escape = single-quote-escape
/ null-character-escape / null-character-escape
``` ```
Go to: _[horizontal-tab-escape](#user-content-horizontal-tab-escape), [backslash-escape](#user-content-backslash-escape), [null-character-escape](#user-content-null-character-escape), [line-feed-escape](#user-content-line-feed-escape), [single-quote-escape](#user-content-single-quote-escape), [double-quote-escape](#user-content-double-quote-escape), [carriage-return-escape](#user-content-carriage-return-escape)_; Go to: _[carriage-return-escape](#user-content-carriage-return-escape), [horizontal-tab-escape](#user-content-horizontal-tab-escape), [null-character-escape](#user-content-null-character-escape), [double-quote-escape](#user-content-double-quote-escape), [single-quote-escape](#user-content-single-quote-escape), [backslash-escape](#user-content-backslash-escape), [line-feed-escape](#user-content-line-feed-escape)_;
<a name="ascii-character-escape"></a> <a name="ascii-character-escape"></a>
@ -863,7 +864,7 @@ string-literal-element = not-double-quote-or-backslash
/ unicode-character-escape / unicode-character-escape
``` ```
Go to: _[not-double-quote-or-backslash](#user-content-not-double-quote-or-backslash), [simple-character-escape](#user-content-simple-character-escape), [ascii-character-escape](#user-content-ascii-character-escape), [unicode-character-escape](#user-content-unicode-character-escape)_; Go to: _[ascii-character-escape](#user-content-ascii-character-escape), [unicode-character-escape](#user-content-unicode-character-escape), [simple-character-escape](#user-content-simple-character-escape), [not-double-quote-or-backslash](#user-content-not-double-quote-or-backslash)_;
The ones above are all the atomic literals The ones above are all the atomic literals
@ -883,7 +884,7 @@ atomic-literal = untyped-literal
/ string-literal / string-literal
``` ```
Go to: _[signed-literal](#user-content-signed-literal), [unsigned-literal](#user-content-unsigned-literal), [field-literal](#user-content-field-literal), [product-group-literal](#user-content-product-group-literal), [boolean-literal](#user-content-boolean-literal), [address-literal](#user-content-address-literal), [string-literal](#user-content-string-literal), [untyped-literal](#user-content-untyped-literal), [character-literal](#user-content-character-literal)_; Go to: _[signed-literal](#user-content-signed-literal), [untyped-literal](#user-content-untyped-literal), [product-group-literal](#user-content-product-group-literal), [unsigned-literal](#user-content-unsigned-literal), [character-literal](#user-content-character-literal), [string-literal](#user-content-string-literal), [field-literal](#user-content-field-literal), [boolean-literal](#user-content-boolean-literal), [address-literal](#user-content-address-literal)_;
After defining the (mostly) alphanumeric tokens above, After defining the (mostly) alphanumeric tokens above,
@ -927,7 +928,7 @@ token = keyword
/ symbol / symbol
``` ```
Go to: _[atomic-literal](#user-content-atomic-literal), [package-name](#user-content-package-name), [annotation-name](#user-content-annotation-name), [symbol](#user-content-symbol), [identifier](#user-content-identifier), [keyword](#user-content-keyword)_; Go to: _[identifier](#user-content-identifier), [keyword](#user-content-keyword), [symbol](#user-content-symbol), [package-name](#user-content-package-name), [annotation-name](#user-content-annotation-name), [atomic-literal](#user-content-atomic-literal)_;
Tokens, comments, and whitespace are lexemes, i.e. lexical units. Tokens, comments, and whitespace are lexemes, i.e. lexical units.
@ -937,7 +938,7 @@ Tokens, comments, and whitespace are lexemes, i.e. lexical units.
lexeme = token / comment / whitespace lexeme = token / comment / whitespace
``` ```
Go to: _[whitespace](#user-content-whitespace), [comment](#user-content-comment), [token](#user-content-token)_; Go to: _[whitespace](#user-content-whitespace), [token](#user-content-token), [comment](#user-content-comment)_;
@ -973,7 +974,7 @@ signed-type = %s"i8" / %s"i16" / %s"i32" / %s"i64" / %s"i128"
integer-type = unsigned-type / signed-type integer-type = unsigned-type / signed-type
``` ```
Go to: _[unsigned-type](#user-content-unsigned-type), [signed-type](#user-content-signed-type)_; Go to: _[signed-type](#user-content-signed-type), [unsigned-type](#user-content-unsigned-type)_;
The integer types, along with the field and group types, The integer types, along with the field and group types,
@ -1020,7 +1021,7 @@ character-type = %s"char"
scalar-type = boolean-type / arithmetic-type / address-type / character-type scalar-type = boolean-type / arithmetic-type / address-type / character-type
``` ```
Go to: _[address-type](#user-content-address-type), [boolean-type](#user-content-boolean-type), [character-type](#user-content-character-type), [arithmetic-type](#user-content-arithmetic-type)_; Go to: _[character-type](#user-content-character-type), [arithmetic-type](#user-content-arithmetic-type), [boolean-type](#user-content-boolean-type), [address-type](#user-content-address-type)_;
Circuit types are denoted by identifiers and the keyword `Self`. Circuit types are denoted by identifiers and the keyword `Self`.
@ -1060,7 +1061,7 @@ or a tuple of one or more dimensions.
array-type = "[" type ";" array-dimensions "]" array-type = "[" type ";" array-dimensions "]"
``` ```
Go to: _[type](#user-content-type), [array-dimensions](#user-content-array-dimensions)_; Go to: _[array-dimensions](#user-content-array-dimensions), [type](#user-content-type)_;
<a name="array-dimensions"></a> <a name="array-dimensions"></a>
@ -1127,7 +1128,7 @@ A literal is either an atomic one or an affine group literal.
literal = atomic-literal / affine-group-literal literal = atomic-literal / affine-group-literal
``` ```
Go to: _[atomic-literal](#user-content-atomic-literal), [affine-group-literal](#user-content-affine-group-literal)_; Go to: _[affine-group-literal](#user-content-affine-group-literal), [atomic-literal](#user-content-atomic-literal)_;
The following rule is not directly referenced in the rules for expressions The following rule is not directly referenced in the rules for expressions
@ -1140,7 +1141,7 @@ a group literal is either a product group literal or an affine group literal.
group-literal = product-group-literal / affine-group-literal group-literal = product-group-literal / affine-group-literal
``` ```
Go to: _[affine-group-literal](#user-content-affine-group-literal), [product-group-literal](#user-content-product-group-literal)_; Go to: _[product-group-literal](#user-content-product-group-literal), [affine-group-literal](#user-content-affine-group-literal)_;
As often done in grammatical language syntax specifications, As often done in grammatical language syntax specifications,
@ -1169,7 +1170,7 @@ primary-expression = identifier
/ circuit-expression / circuit-expression
``` ```
Go to: _[expression](#user-content-expression), [array-expression](#user-content-array-expression), [literal](#user-content-literal), [identifier](#user-content-identifier), [circuit-expression](#user-content-circuit-expression), [tuple-expression](#user-content-tuple-expression)_; Go to: _[array-expression](#user-content-array-expression), [expression](#user-content-expression), [circuit-expression](#user-content-circuit-expression), [identifier](#user-content-identifier), [tuple-expression](#user-content-tuple-expression), [literal](#user-content-literal)_;
Tuple expressions construct tuples. Tuple expressions construct tuples.
@ -1230,7 +1231,7 @@ Go to: _[expression](#user-content-expression), [array-dimensions](#user-content
array-construction = array-inline-construction / array-repeat-construction array-construction = array-inline-construction / array-repeat-construction
``` ```
Go to: _[array-inline-construction](#user-content-array-inline-construction), [array-repeat-construction](#user-content-array-repeat-construction)_; Go to: _[array-repeat-construction](#user-content-array-repeat-construction), [array-inline-construction](#user-content-array-inline-construction)_;
<a name="array-expression"></a> <a name="array-expression"></a>
@ -1317,7 +1318,7 @@ postfix-expression = primary-expression
/ postfix-expression "[" [expression] ".." [expression] "]" / postfix-expression "[" [expression] ".." [expression] "]"
``` ```
Go to: _[natural](#user-content-natural), [identifier](#user-content-identifier), [circuit-type](#user-content-circuit-type), [primary-expression](#user-content-primary-expression), [function-arguments](#user-content-function-arguments), [postfix-expression](#user-content-postfix-expression), [expression](#user-content-expression)_; Go to: _[identifier](#user-content-identifier), [circuit-type](#user-content-circuit-type), [function-arguments](#user-content-function-arguments), [natural](#user-content-natural), [primary-expression](#user-content-primary-expression), [expression](#user-content-expression), [postfix-expression](#user-content-postfix-expression)_;
Unary operators have the highest operator precedence. Unary operators have the highest operator precedence.
@ -1331,7 +1332,7 @@ unary-expression = postfix-expression
/ "-" unary-expression / "-" unary-expression
``` ```
Go to: _[postfix-expression](#user-content-postfix-expression), [unary-expression](#user-content-unary-expression)_; Go to: _[unary-expression](#user-content-unary-expression), [postfix-expression](#user-content-postfix-expression)_;
Next in the operator precedence is exponentiation, Next in the operator precedence is exponentiation,
@ -1357,7 +1358,7 @@ multiplicative-expression = exponential-expression
/ multiplicative-expression "/" exponential-expression / multiplicative-expression "/" exponential-expression
``` ```
Go to: _[exponential-expression](#user-content-exponential-expression), [multiplicative-expression](#user-content-multiplicative-expression)_; Go to: _[multiplicative-expression](#user-content-multiplicative-expression), [exponential-expression](#user-content-exponential-expression)_;
Then there are addition and subtraction, both left-assocative. Then there are addition and subtraction, both left-assocative.
@ -1408,7 +1409,7 @@ conjunctive-expression = equality-expression
/ conjunctive-expression "&&" equality-expression / conjunctive-expression "&&" equality-expression
``` ```
Go to: _[equality-expression](#user-content-equality-expression), [conjunctive-expression](#user-content-conjunctive-expression)_; Go to: _[conjunctive-expression](#user-content-conjunctive-expression), [equality-expression](#user-content-equality-expression)_;
Next come disjunctive expressions, left-associative. Next come disjunctive expressions, left-associative.
@ -1419,7 +1420,7 @@ disjunctive-expression = conjunctive-expression
/ disjunctive-expression "||" conjunctive-expression / disjunctive-expression "||" conjunctive-expression
``` ```
Go to: _[conjunctive-expression](#user-content-conjunctive-expression), [disjunctive-expression](#user-content-disjunctive-expression)_; Go to: _[disjunctive-expression](#user-content-disjunctive-expression), [conjunctive-expression](#user-content-conjunctive-expression)_;
Finally we have conditional expressions. Finally we have conditional expressions.
@ -1432,7 +1433,7 @@ conditional-expression = disjunctive-expression
":" conditional-expression ":" conditional-expression
``` ```
Go to: _[expression](#user-content-expression), [disjunctive-expression](#user-content-disjunctive-expression), [conditional-expression](#user-content-conditional-expression)_; Go to: _[disjunctive-expression](#user-content-disjunctive-expression), [expression](#user-content-expression), [conditional-expression](#user-content-conditional-expression)_;
Those above are all the expressions. Those above are all the expressions.
@ -1465,7 +1466,7 @@ statement = expression-statement
/ block / block
``` ```
Go to: _[constant-declaration](#user-content-constant-declaration), [block](#user-content-block), [variable-declaration](#user-content-variable-declaration), [conditional-statement](#user-content-conditional-statement), [return-statement](#user-content-return-statement), [assignment-statement](#user-content-assignment-statement), [expression-statement](#user-content-expression-statement), [loop-statement](#user-content-loop-statement), [console-statement](#user-content-console-statement)_; Go to: _[loop-statement](#user-content-loop-statement), [assignment-statement](#user-content-assignment-statement), [variable-declaration](#user-content-variable-declaration), [expression-statement](#user-content-expression-statement), [conditional-statement](#user-content-conditional-statement), [block](#user-content-block), [console-statement](#user-content-console-statement), [return-statement](#user-content-return-statement), [constant-declaration](#user-content-constant-declaration)_;
<a name="block"></a> <a name="block"></a>
@ -1508,7 +1509,7 @@ variable-declaration = %s"let" identifier-or-identifiers [ ":" type ]
"=" expression ";" "=" expression ";"
``` ```
Go to: _[type](#user-content-type), [expression](#user-content-expression), [identifier-or-identifiers](#user-content-identifier-or-identifiers)_; Go to: _[type](#user-content-type), [identifier-or-identifiers](#user-content-identifier-or-identifiers), [expression](#user-content-expression)_;
<a name="constant-declaration"></a> <a name="constant-declaration"></a>
@ -1517,7 +1518,7 @@ constant-declaration = %s"const" identifier-or-identifiers [ ":" type ]
"=" expression ";" "=" expression ";"
``` ```
Go to: _[identifier-or-identifiers](#user-content-identifier-or-identifiers), [type](#user-content-type), [expression](#user-content-expression)_; Go to: _[type](#user-content-type), [expression](#user-content-expression), [identifier-or-identifiers](#user-content-identifier-or-identifiers)_;
<a name="identifier-or-identifiers"></a> <a name="identifier-or-identifiers"></a>
@ -1540,7 +1541,7 @@ Note that blocks are required in all branches, not merely statements.
branch = %s"if" expression block branch = %s"if" expression block
``` ```
Go to: _[block](#user-content-block), [expression](#user-content-expression)_; Go to: _[expression](#user-content-expression), [block](#user-content-block)_;
<a name="conditional-statement"></a> <a name="conditional-statement"></a>
@ -1550,7 +1551,7 @@ conditional-statement = branch
/ branch %s"else" conditional-statement / branch %s"else" conditional-statement
``` ```
Go to: _[branch](#user-content-branch), [conditional-statement](#user-content-conditional-statement), [block](#user-content-block)_; Go to: _[branch](#user-content-branch), [block](#user-content-block), [conditional-statement](#user-content-conditional-statement)_;
A loop statement implicitly defines a loop variable A loop statement implicitly defines a loop variable
@ -1606,7 +1607,7 @@ console-call = assert-call
/ print-call / print-call
``` ```
Go to: _[assert-call](#user-content-assert-call), [print-call](#user-content-print-call)_; Go to: _[print-call](#user-content-print-call), [assert-call](#user-content-assert-call)_;
<a name="assert-call"></a> <a name="assert-call"></a>
@ -1665,7 +1666,7 @@ function-declaration = *annotation %s"function" identifier
block block
``` ```
Go to: _[block](#user-content-block), [identifier](#user-content-identifier), [function-parameters](#user-content-function-parameters), [type](#user-content-type)_; Go to: _[identifier](#user-content-identifier), [function-parameters](#user-content-function-parameters), [type](#user-content-type), [block](#user-content-block)_;
<a name="function-parameters"></a> <a name="function-parameters"></a>
@ -1675,7 +1676,7 @@ function-parameters = self-parameter
/ function-inputs / function-inputs
``` ```
Go to: _[function-inputs](#user-content-function-inputs), [self-parameter](#user-content-self-parameter)_; Go to: _[self-parameter](#user-content-self-parameter), [function-inputs](#user-content-function-inputs)_;
<a name="self-parameter"></a> <a name="self-parameter"></a>
@ -1744,7 +1745,7 @@ circuit-declaration = %s"circuit" identifier
*member-function-declaration "}" *member-function-declaration "}"
``` ```
Go to: _[identifier](#user-content-identifier), [member-variable-declarations](#user-content-member-variable-declarations)_; Go to: _[member-variable-declarations](#user-content-member-variable-declarations), [identifier](#user-content-identifier)_;
An import declaration consists of the `import` keyword An import declaration consists of the `import` keyword
@ -1766,7 +1767,7 @@ by using an explicit package name before the package path.
import-declaration = %s"import" package-name "." package-path ";" import-declaration = %s"import" package-name "." package-path ";"
``` ```
Go to: _[package-path](#user-content-package-path), [package-name](#user-content-package-name)_; Go to: _[package-name](#user-content-package-name), [package-path](#user-content-package-path)_;
<a name="package-path"></a> <a name="package-path"></a>
@ -1777,7 +1778,7 @@ package-path = "*"
/ "(" package-path *( "," package-path ) [","] ")" / "(" package-path *( "," package-path ) [","] ")"
``` ```
Go to: _[package-name](#user-content-package-name), [identifier](#user-content-identifier), [package-path](#user-content-package-path)_; Go to: _[identifier](#user-content-identifier), [package-path](#user-content-package-path), [package-name](#user-content-package-name)_;
Finally, we define a file as a sequence of zero or more declarations. Finally, we define a file as a sequence of zero or more declarations.
@ -1792,7 +1793,7 @@ declaration = import-declaration
/ constant-declaration / constant-declaration
``` ```
Go to: _[function-declaration](#user-content-function-declaration), [circuit-declaration](#user-content-circuit-declaration), [constant-declaration](#user-content-constant-declaration), [import-declaration](#user-content-import-declaration)_; Go to: _[function-declaration](#user-content-function-declaration), [constant-declaration](#user-content-constant-declaration), [import-declaration](#user-content-import-declaration), [circuit-declaration](#user-content-circuit-declaration)_;
<a name="file"></a> <a name="file"></a>

View File

@ -421,10 +421,7 @@ keyword = %s"address"
/ %s"u64" / %s"u64"
/ %s"u128" / %s"u128"
; The following rules define (ASCII) ; The following rules define (ASCII) letters.
; digits and (uppercase and lowercase) letters.
digit = %x30-39 ; 0-9
uppercase-letter = %x41-5A ; A-Z uppercase-letter = %x41-5A ; A-Z
@ -432,30 +429,34 @@ lowercase-letter = %x61-7A ; a-z
letter = uppercase-letter / lowercase-letter letter = uppercase-letter / lowercase-letter
; The following rules defines (ASCII) octal and hexadecimal digits. ; The following rules defines (ASCII) decimal, octal, and hexadecimal digits.
; Note that the latter are case-insensitive. ; Note that the latter are case-insensitive.
decimal-digit = %x30-39 ; 0-9
octal-digit = %x30-37 ; 0-7 octal-digit = %x30-37 ; 0-7
hexadecimal-digit = digit / "a" / "b" / "c" / "d" / "e" / "f" hexadecimal-digit = decimal-digit / "a" / "b" / "c" / "d" / "e" / "f"
; An identifier is a non-empty sequence of letters, digits, and underscores, ; An identifier is a non-empty sequence of
; letters, (decimal) digits, and underscores,
; starting with a letter. ; starting with a letter.
; It must not be a keyword: this is an extra-grammatical requirement. ; It must not be a keyword: this is an extra-grammatical requirement.
; It must also not be or start with `aleo1`, ; It must also not be or start with `aleo1`,
; because that is used for address literals: ; because that is used for address literals:
; this is another extra-grammatical requirement. ; this is another extra-grammatical requirement.
identifier = letter *( letter / digit / "_" ) identifier = letter *( letter / decimal-digit / "_" )
; but not a keyword or a boolean literal or aleo1... ; but not a keyword or a boolean literal or aleo1...
; A package name consists of one or more segments separated by single dashes, ; A package name consists of one or more segments separated by single dashes,
; where each segment is a non-empty sequence of lowercase letters and digits. ; where each segment is a non-empty sequence of
; lowercase letters and (decimal) digits.
; Similarly to an identifier, a package name must not be a keyword ; Similarly to an identifier, a package name must not be a keyword
; and must not be or start with `aleo1`. ; and must not be or start with `aleo1`.
package-name = lowercase-letter *( lowercase-letter / digit ) package-name = lowercase-letter *( lowercase-letter / decimal-digit )
*( "-" 1*( lowercase-letter / digit ) ) *( "-" 1*( lowercase-letter / decimal-digit ) )
; but not a keyword or a boolean literal or aleo1... ; but not a keyword or a boolean literal or aleo1...
; Note that, grammatically, identifiers are also package names. ; Note that, grammatically, identifiers are also package names.
@ -465,10 +466,10 @@ package-name = lowercase-letter *( lowercase-letter / digit )
annotation-name = "@" identifier annotation-name = "@" identifier
; A natural (number) is a sequence of one or more digits. ; A natural (number) is a sequence of one or more decimal digits.
; We allow leading zeros, e.g. `007`. ; We allow leading zeros, e.g. `007`.
natural = 1*digit natural = 1*decimal-digit
; An integer (number) is either a natural or its negation. ; An integer (number) is either a natural or its negation.
; We allow leading zeros also in negative numbers, e.g. `-007`. ; We allow leading zeros also in negative numbers, e.g. `-007`.
@ -504,10 +505,10 @@ product-group-literal = integer %s"group"
boolean-literal = %s"true" / %s"false" boolean-literal = %s"true" / %s"false"
; An address literal starts with `aleo1` ; An address literal starts with `aleo1`
; and continues with exactly 58 lowercase letters and digits. ; and continues with exactly 58 lowercase letters and (decimal) digits.
; Thus an address always consists of 63 characters. ; Thus an address always consists of 63 characters.
address-literal = %s"aleo1" 58( lowercase-letter / digit ) address-literal = %s"aleo1" 58( lowercase-letter / decimal-digit )
; A character literal consists of an element surrounded by single quotes. ; A character literal consists of an element surrounded by single quotes.
; The element is any character other than single quote or backslash, ; The element is any character other than single quote or backslash,

View File

@ -37,8 +37,5 @@ version = "1.5.3"
version = "1.7.0" version = "1.7.0"
features = [ "serde-1" ] features = [ "serde-1" ]
[dependencies.thiserror]
version = "1.0"
[dependencies.tracing] [dependencies.tracing]
version = "0.1" version = "0.1"

View File

@ -18,8 +18,7 @@ use leo_errors::{CliError, LeoError, Result};
use reqwest::{ use reqwest::{
blocking::{multipart::Form, Client, Response}, blocking::{multipart::Form, Client, Response},
Method, Method, StatusCode,
StatusCode,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{collections::HashMap, path::PathBuf}; use std::{collections::HashMap, path::PathBuf};

View File

@ -18,8 +18,7 @@ use crate::{commands::Command, context::Context};
use leo_compiler::{ use leo_compiler::{
compiler::{thread_leaked_context, Compiler}, compiler::{thread_leaked_context, Compiler},
group::targets::edwards_bls12::EdwardsGroupType, group::targets::edwards_bls12::EdwardsGroupType,
AstSnapshotOptions, AstSnapshotOptions, CompilerOptions,
CompilerOptions,
}; };
use leo_errors::{CliError, Result}; use leo_errors::{CliError, Result};
use leo_package::{ use leo_package::{

View File

@ -20,8 +20,7 @@ use leo_errors::{CliError, Result};
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::{Read, Write}, io::{Read, Write},
path::Path, path::Path,

View File

@ -18,9 +18,7 @@ use leo_errors::{CliError, Result};
use std::{ use std::{
fs::{ fs::{
create_dir_all, create_dir_all, File, {self},
File,
{self},
}, },
io::prelude::*, io::prelude::*,
path::{Path, PathBuf}, path::{Path, PathBuf},

View File

@ -23,19 +23,7 @@ pub mod updater;
use commands::{ use commands::{
package::{Add, Clone, Login, Logout, Publish, Remove}, package::{Add, Clone, Login, Logout, Publish, Remove},
Build, Build, Clean, Command, Deploy, Init, Lint, New, Prove, Run, Setup, Test, Update, Watch,
Clean,
Command,
Deploy,
Init,
Lint,
New,
Prove,
Run,
Setup,
Test,
Update,
Watch,
}; };
use leo_errors::Result; use leo_errors::Result;
@ -182,7 +170,6 @@ enum CommandOpts {
} }
fn main() { fn main() {
color_backtrace::install();
handle_error(run_with_args(Opt::from_args())) handle_error(run_with_args(Opt::from_args()))
} }
@ -190,10 +177,13 @@ fn main() {
fn run_with_args(opt: Opt) -> Result<()> { fn run_with_args(opt: Opt) -> Result<()> {
if !opt.quiet { if !opt.quiet {
// Init logger with optional debug flag. // Init logger with optional debug flag.
logger::init_logger("leo", match opt.debug { logger::init_logger(
"leo",
match opt.debug {
false => 1, false => 1,
true => 2, true => 2,
})?; },
)?;
} }
// Get custom root folder and create context for it. // Get custom root folder and create context for it.
@ -253,7 +243,7 @@ fn handle_error<T>(res: Result<T>) -> T {
#[cfg(test)] #[cfg(test)]
mod cli_tests { mod cli_tests {
use crate::{run_with_args, Opt}; use crate::{run_with_args, Opt};
use leo_errors::Result; use leo_errors::{CliError, Result};
use std::path::PathBuf; use std::path::PathBuf;
use structopt::StructOpt; use structopt::StructOpt;
@ -262,7 +252,7 @@ mod cli_tests {
// Runs Command from cmd-like argument "leo run --arg1 --arg2". // Runs Command from cmd-like argument "leo run --arg1 --arg2".
fn run_cmd(args: &str, path: &Option<PathBuf>) -> Result<()> { fn run_cmd(args: &str, path: &Option<PathBuf>) -> Result<()> {
let args = args.split(' ').collect::<Vec<&str>>(); let args = args.split(' ').collect::<Vec<&str>>();
let mut opts = Opt::from_iter_safe(args).unwrap(); let mut opts = Opt::from_iter_safe(args).map_err(CliError::opt_args_error)?;
if path.is_some() { if path.is_some() {
opts.path = path.clone(); opts.path = path.clone();
@ -287,9 +277,6 @@ mod cli_tests {
assert!(run_cmd("leo build", &path).is_ok()); assert!(run_cmd("leo build", &path).is_ok());
assert!(run_cmd("leo -q build", &path).is_ok()); assert!(run_cmd("leo -q build", &path).is_ok());
assert!(run_cmd("leo --path ../../examples/no-directory-there build", &None).is_err());
assert!(run_cmd("leo -v build", &None).is_err());
} }
#[test] #[test]

View File

@ -20,14 +20,7 @@ use std::path::PathBuf;
use crate::{ use crate::{
commands::{ commands::{
package::{Login, Logout}, package::{Login, Logout},
Build, Build, Command, Prove, Run, Setup, Test, Update, UpdateAutomatic,
Command,
Prove,
Run,
Setup,
Test,
Update,
UpdateAutomatic,
}, },
context::{create_context, Context}, context::{create_context, Context},
}; };
@ -150,7 +143,8 @@ pub fn test_pedersen_hash() -> Result<()> {
#[test] #[test]
pub fn test_logout() -> Result<()> { pub fn test_logout() -> Result<()> {
(Logout {}).apply(context()?, ())?; let logout = (Logout {}).apply(context()?, ());
assert!(logout.is_err());
Ok(()) Ok(())
} }

View File

@ -24,8 +24,7 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -23,8 +23,7 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -23,8 +23,7 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -23,8 +23,7 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -23,8 +23,7 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -23,8 +23,7 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -23,8 +23,7 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -20,12 +20,8 @@ use crate::{
imports::IMPORTS_DIRECTORY_NAME, imports::IMPORTS_DIRECTORY_NAME,
inputs::{INPUTS_DIRECTORY_NAME, INPUT_FILE_EXTENSION, STATE_FILE_EXTENSION}, inputs::{INPUTS_DIRECTORY_NAME, INPUT_FILE_EXTENSION, STATE_FILE_EXTENSION},
outputs::{ outputs::{
CHECKSUM_FILE_EXTENSION, CHECKSUM_FILE_EXTENSION, CIRCUIT_FILE_EXTENSION, OUTPUTS_DIRECTORY_NAME, PROOF_FILE_EXTENSION,
CIRCUIT_FILE_EXTENSION, PROVING_KEY_FILE_EXTENSION, VERIFICATION_KEY_FILE_EXTENSION,
OUTPUTS_DIRECTORY_NAME,
PROOF_FILE_EXTENSION,
PROVING_KEY_FILE_EXTENSION,
VERIFICATION_KEY_FILE_EXTENSION,
}, },
root::{MANIFEST_FILENAME, README_FILENAME}, root::{MANIFEST_FILENAME, README_FILENAME},
source::{SOURCE_DIRECTORY_NAME, SOURCE_FILE_EXTENSION}, source::{SOURCE_DIRECTORY_NAME, SOURCE_FILE_EXTENSION},
@ -36,8 +32,7 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, File, {self},
{self},
}, },
io::{Read, Write}, io::{Read, Write},
path::Path, path::Path,

View File

@ -22,8 +22,7 @@ pub mod manifest;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use std::{ use std::{
cell::RefCell, cell::RefCell,
env, env, fs,
fs,
path::PathBuf, path::PathBuf,
sync::atomic::{AtomicUsize, Ordering}, sync::atomic::{AtomicUsize, Ordering},
}; };

View File

@ -558,11 +558,11 @@ impl ParserContext {
pub fn parse_tuple_expression(&mut self, span: &Span) -> Result<Expression> { pub fn parse_tuple_expression(&mut self, span: &Span) -> Result<Expression> {
if let Some((left, right, span)) = self.eat_group_partial().transpose()? { if let Some((left, right, span)) = self.eat_group_partial().transpose()? {
return Ok(Expression::Value(ValueExpression::Group(Box::new(GroupValue::Tuple( return Ok(Expression::Value(ValueExpression::Group(Box::new(GroupValue::Tuple(
Box::new(GroupTuple { GroupTuple {
span, span,
x: left, x: left,
y: right, y: right,
}), },
))))); )))));
} }
let mut args = Vec::new(); let mut args = Vec::new();

View File

@ -193,17 +193,17 @@ impl ParserContext {
}) })
} else if self.eat(Token::As).is_some() { } else if self.eat(Token::As).is_some() {
let alias = self.expect_ident()?; let alias = self.expect_ident()?;
Ok(PackageAccess::Symbol(Box::new(ImportSymbol { Ok(PackageAccess::Symbol(ImportSymbol {
span: &name.span + &alias.span, span: &name.span + &alias.span,
symbol: name, symbol: name,
alias: Some(alias), alias: Some(alias),
}))) }))
} else { } else {
Ok(PackageAccess::Symbol(Box::new(ImportSymbol { Ok(PackageAccess::Symbol(ImportSymbol {
span: name.span.clone(), span: name.span.clone(),
symbol: name, symbol: name,
alias: None, alias: None,
}))) }))
} }
} }
} }
@ -371,7 +371,7 @@ impl ParserContext {
let peeked = self.peek()?.clone(); let peeked = self.peek()?.clone();
if peeked.token == Token::Function || peeked.token == Token::At { if peeked.token == Token::Function || peeked.token == Token::At {
let function = self.parse_function_declaration()?; let function = self.parse_function_declaration()?;
Ok(CircuitMember::CircuitFunction(Box::new(function.1))) Ok(CircuitMember::CircuitFunction(function.1))
} else { } else {
return Err(ParserError::unexpected( return Err(ParserError::unexpected(
&peeked.token, &peeked.token,
@ -396,10 +396,13 @@ impl ParserContext {
self.expect(Token::LeftCurly)?; self.expect(Token::LeftCurly)?;
let members = self.parse_circuit_declaration()?; let members = self.parse_circuit_declaration()?;
Ok((name.clone(), Circuit { Ok((
name.clone(),
Circuit {
circuit_name: name, circuit_name: name,
members, members,
})) },
))
} }
/// ///
@ -421,9 +424,7 @@ impl ParserContext {
// Handle `mut self`. // Handle `mut self`.
name.span = &mutable.span + &name.span; name.span = &mutable.span + &name.span;
name.name = "mut self".to_string().into(); name.name = "mut self".to_string().into();
return Ok(FunctionInput::MutSelfKeyword(Box::new(MutSelfKeyword { return Ok(FunctionInput::MutSelfKeyword(MutSelfKeyword { identifier: name }));
identifier: name,
})));
} else if let Some(const_) = &const_ { } else if let Some(const_) = &const_ {
// Handle `const self`. // Handle `const self`.
name.span = &const_.span + &name.span; name.span = &const_.span + &name.span;
@ -440,13 +441,13 @@ impl ParserContext {
self.expect(Token::Colon)?; self.expect(Token::Colon)?;
let type_ = self.parse_type()?.0; let type_ = self.parse_type()?.0;
Ok(FunctionInput::Variable(Box::new(FunctionInputVariable { Ok(FunctionInput::Variable(FunctionInputVariable {
const_: const_.is_some(), const_: const_.is_some(),
mutable: const_.is_none(), mutable: const_.is_none(),
type_, type_,
span: name.span.clone(), span: name.span.clone(),
identifier: name, identifier: name,
}))) }))
} }
/// ///
@ -476,14 +477,17 @@ impl ParserContext {
None None
}; };
let block = self.parse_block()?; let block = self.parse_block()?;
Ok((name.clone(), Function { Ok((
name.clone(),
Function {
annotations, annotations,
identifier: name, identifier: name,
input: inputs, input: inputs,
output, output,
span: start + block.span.clone(), span: start + block.span.clone(),
block, block,
})) },
))
} }
/// ///

View File

@ -195,7 +195,7 @@ mod tests {
*= *=
+ +
+= +=
,
- -
-= -=
-> ->
@ -231,6 +231,7 @@ mod tests {
for SpannedToken { token, .. } in tokens.iter() { for SpannedToken { token, .. } in tokens.iter() {
output += &format!("{} ", token.to_string()); output += &format!("{} ", token.to_string());
} }
// & &= | |= ^ ^= ~ << <<= >> >>= >>> >>>= % %= ||= &&= // & &= | |= ^ ^= ~ << <<= >> >>= >>> >>>= % %= ||= &&=
assert_eq!( assert_eq!(
output, output,

View File

@ -30,18 +30,18 @@ path = "../input"
version = "1.5.3" version = "1.5.3"
[dependencies.snarkvm-algorithms] [dependencies.snarkvm-algorithms]
version = "0.7.4" version = "0.7.6"
[dependencies.snarkvm-curves] [dependencies.snarkvm-curves]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.snarkvm-dpc] [dependencies.snarkvm-dpc]
version = "0.7.5" version = "0.7.7"
features = [ "testnet1" ] features = [ "testnet1" ]
[dependencies.snarkvm-utilities] [dependencies.snarkvm-utilities]
version = "0.7.4" version = "0.7.6"
[dependencies.indexmap] [dependencies.indexmap]
version = "1.7.0" version = "1.7.0"
@ -53,8 +53,5 @@ version = "0.8"
[dependencies.rand_xorshift] [dependencies.rand_xorshift]
version = "0.3" version = "0.3"
[dependencies.thiserror]
version = "1.0"
[dev-dependencies.rand_core] [dev-dependencies.rand_core]
version = "0.6.3" version = "0.6.3"

View File

@ -56,8 +56,7 @@ pub fn verify_local_data_commitment(dpc: &SystemParameters<Components>, ast_inpu
// Select local data commitment input bytes. // Select local data commitment input bytes.
let is_death = leaf_index < (Components::NUM_INPUT_RECORDS as u32); let is_death = leaf_index < (Components::NUM_INPUT_RECORDS as u32);
let input_bytes = if is_death { let input_bytes = if is_death {
to_bytes_le![record_serial_number, record_commitment, memo, network_id] to_bytes_le![record_serial_number, record_commitment, memo, network_id].map_err(StateError::state_io_error)?
.map_err(StateError::state_io_error)?
} else { } else {
to_bytes_le![record_commitment, memo, network_id].map_err(StateError::state_io_error)? to_bytes_le![record_commitment, memo, network_id].map_err(StateError::state_io_error)?
}; };

View File

@ -53,9 +53,7 @@ pub fn input_to_bytes(input: InputValue) -> Result<Vec<u8>> {
for input in input_array { for input in input_array {
let integer_string = input_to_integer_string(input)?; let integer_string = input_to_integer_string(input)?;
let byte = integer_string let byte = integer_string.parse::<u8>().map_err(StateError::parse_int_error)?;
.parse::<u8>()
.map_err(StateError::parse_int_error)?;
result_vec.push(byte); result_vec.push(byte);
} }

View File

@ -18,7 +18,7 @@ license = "GPL-3.0"
edition = "2018" edition = "2018"
[dependencies.snarkvm-curves] [dependencies.snarkvm-curves]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.leo-errors] [dependencies.leo-errors]
@ -30,14 +30,14 @@ version = "0.6.5"
default-features = false default-features = false
[dependencies.snarkvm-fields] [dependencies.snarkvm-fields]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.snarkvm-gadgets] [dependencies.snarkvm-gadgets]
version = "0.7.5" version = "0.7.7"
[dependencies.snarkvm-r1cs] [dependencies.snarkvm-r1cs]
version = "0.7.5" version = "0.7.7"
default-features = false default-features = false
[dependencies.num-bigint] [dependencies.num-bigint]

View File

@ -174,11 +174,14 @@ pub fn run_tests<T: Runner>(runner: &T, expectation_category: &str) {
if errors.is_empty() { if errors.is_empty() {
if expectations.is_none() { if expectations.is_none() {
outputs.push((expectation_path, TestExpectation { outputs.push((
expectation_path,
TestExpectation {
namespace: config.namespace, namespace: config.namespace,
expectation: config.expectation, expectation: config.expectation,
outputs: new_outputs, outputs: new_outputs,
})); },
));
} }
pass_categories += 1; pass_categories += 1;
} else { } else {