Skip to content
This repository was archived by the owner on May 4, 2026. It is now read-only.

Commit 26ee6b1

Browse files
author
Mohammad Fawaz
committed
A few fixes
1 parent 9d42653 commit 26ee6b1

7 files changed

Lines changed: 32 additions & 33 deletions

File tree

documentation/guides/08_testing.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Developers can add multiple `leo` files to the test directory but must ensure th
4747

4848
The `example_program.leo` program contains an entry function which returns the sum of two `u32` inputs.
4949

50-
```Leo
50+
```leo
5151
fn simple_addition(public a: u32, b: u32) -> u32 {
5252
let c: u32 = a + b;
5353
return c;
@@ -56,7 +56,7 @@ fn simple_addition(public a: u32, b: u32) -> u32 {
5656

5757
The `test_example_program.leo` contains two tests to ensure that the function logic returns a correct output and fails when the output does not match the sum of the input values.
5858

59-
```Leo
59+
```leo
6060
@test
6161
fn test_simple_addition() {
6262
let result: u32 = example_program.aleo::simple_addition(2u32, 3u32);
@@ -66,7 +66,7 @@ fn test_simple_addition() {
6666

6767
The `@should_fail` annotation should be added after the `@test` annotation for tests that are expected to fail.
6868

69-
```Leo
69+
```leo
7070
@test
7171
@should_fail
7272
fn test_simple_addition_fail() {
@@ -79,7 +79,7 @@ fn test_simple_addition_fail() {
7979

8080
Developers can test that record and struct fields match their expected values. In `example_program.leo`, a record is minted by an entry function shown here:
8181

82-
```Leo
82+
```leo
8383
record Example {
8484
owner: address,
8585
x: field,
@@ -95,7 +95,7 @@ fn mint_record(x: field) -> Example {
9595

9696
The corresponding test in `test_example_program.leo` checks that the Record field contains the correct value:
9797

98-
```Leo
98+
```leo
9999
@test
100100
fn test_record_maker() {
101101
let r: example_program.aleo::Example = example_program.aleo::mint_record(0field);

documentation/language/02_structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ The visibility qualifier may be specified as `constant`, `public`, or `private`.
169169

170170
Record data structures must always contain a component named `owner` of type `address`, as shown below. When passing a record as input to a program function, the `_nonce: group` and `_version: u8` components are also required but do not need to be declared in the Leo program. They are inserted automatically by the compiler.
171171

172-
```aleo showLineNumbers
172+
```leo showLineNumbers
173173
record Token {
174174
// The token owner.
175175
owner: address,

documentation/language/03_data_types.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,17 @@ struct Bar {
171171
}
172172
173173
// Array of structs
174-
let arr_of_structs: [Bar; 2] = [Bar { data: 1u8 }, Bar { data: 2u8 }];
174+
let arr_of_structs: [Bar; 2] = [
175+
Bar { data: [1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] },
176+
Bar { data: [2u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] },
177+
];
175178
```
176179

177180
Arrays only support constant accesses. The accessor expression must be a constant expression (known at compile-time).
178181

179182
```leo
180183
// Access the field of a struct within an array
181-
fn foo(a: [Bar; 8]) -> u8 {
184+
fn foo(a: [Bar; 8]) -> [u8; 8] {
182185
return a[0u8].data;
183186
}
184187
```
@@ -207,10 +210,10 @@ Leo supports tuples. Tuple types are declared as `(type1, type2, ...)` and canno
207210
Tuples can contain primitive data types, structs, arrays, or nested tuples. Structs and records can also contain tuples.
208211

209212
```leo
210-
// Initialize a boolean array of length 4
213+
// Initialize a tuple of mixed types
211214
let tup: (u8,u8,bool) = (1u8,1u8,true);
212215
213-
// Nested array
216+
// Nested tuple
214217
let nested: [[bool; 2]; 2] = [[true, false], [true, false]];
215218
```
216219

@@ -226,7 +229,7 @@ struct Bar {
226229
data: (u8,u8),
227230
}
228231
229-
// Tuple of structs
232+
// Array of structs with tuple fields
230233
let tup_of_structs: [Bar; 2] = [Bar { data: (1u8,1u8) }, Bar { data: (2u8,2u8) }];
231234
```
232235

@@ -293,7 +296,7 @@ Records contain component declarations `{visibility} {name}: {type},`. Names of
293296

294297
Record data structures must always contain a component named `owner` of type `address`, as shown below. When passing a record as input to a program function, the `_nonce: group` and `_version: u8` components are also required but do not need to be declared in the Leo program. They are inserted automatically by the compiler.
295298

296-
```aleo showLineNumbers
299+
```leo showLineNumbers
297300
record Token {
298301
// The token owner.
299302
owner: address,

documentation/language/05_control_flow.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar_label: Control Flow
66

77
[general tags]: # "loop, conditional, return"
88

9-
### Conditional Statements
9+
## Conditional Statements
1010

1111
Conditional statements are declared as `if {condition} { ... } else if {condition} { ... } else { ... }`.
1212
Conditional statements can be nested.
@@ -30,7 +30,7 @@ let a: u8 = 1u8;
3030
a = (a == 1u8) ? a + 1u8 : ((a == 2u8) ? a + 2u8 : a + 3u8);
3131
```
3232

33-
### Return Statements
33+
## Return Statements
3434

3535
Return statements are declared as `return {expression};`.
3636

@@ -46,7 +46,7 @@ Return statements are declared as `return {expression};`.
4646
}
4747
```
4848

49-
### For Loops
49+
## For Loops
5050

5151
For loops are declared as `for {variable: type} in {lower bound}..{upper bound}`.
5252
The loop bounds must be integer constants of the same type. Furthermore, if

documentation/language/08_cheatsheet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ let get_or_use_bal: u64 = balances.get_or_use(receiver, 0u64);
398398
399399
// Modifying
400400
balances.set(receiver, 100u64);
401-
balances.remove(balances, receiver);
401+
balances.remove(receiver);
402402
403403
// External mappings (read-only)
404404
let ext_contains: bool = external_program.aleo::balances.contains(receiver);
@@ -492,7 +492,7 @@ let height: u32 = block.height; // Height of current block
492492
let now: i64 = block.timestamp; // Timestamp of current block
493493
let this: address = self.address; // Address of program
494494
let caller: address = self.caller; // Address of function caller
495-
let checksum: [u8, 32] = self.checksum; // Checksum of a program
495+
let checksum: [u8; 32] = self.checksum; // Checksum of a program
496496
let edition: u16 = self.edition; // Edition of a program
497497
let owner: address = self.program_owner; // Address that deployed a program
498498
let signer: address = self.signer; // Address of tx signer (origin)

documentation/language/programs_in_practice/interfaces.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ interface Transfer {
5959
6060
interface Pausable {
6161
mapping paused: address => bool;
62-
fn pause() -> bool;
62+
fn pause() -> (bool, Final);
6363
}
6464
6565
// my_token.aleo must satisfy both Transfer and Pausable
@@ -75,13 +75,10 @@ program my_token.aleo : Transfer + Pausable {
7575
return Token { owner: to, balance: input.balance - amount };
7676
}
7777
78-
async fn pause() -> (bool, Future) {
79-
let f: Future = finalize_pause(self.caller);
80-
return (true, f);
81-
}
82-
83-
async function finalize_pause(caller: address) {
84-
Mapping::set(paused, caller, true);
78+
fn pause() -> (bool, Final) {
79+
return (true, final {
80+
Mapping::set(paused, self.caller, true);
81+
});
8582
}
8683
}
8784
```
@@ -156,18 +153,17 @@ Dynamic calls allow the callee to be determined at runtime. The caller still kno
156153
```leo
157154
// Dynamic: any program that implements TokenStandard can be called
158155
fn route_transfer_dynamic(token_program: identifier, to: address, amount: u64) {
159-
return token_a.aleo::TokenStandard@(token_program)::transfer_public(to, amount);
156+
return TokenStandard@(token_program)::transfer_public(to, amount);
160157
}
161158
```
162159

163160
The syntax is:
164161
```
165-
qualifier.aleo::Interface@(target)::method(args)
162+
Interface@(target)::method(args)
166163
```
167164
where:
168-
- `qualifier.aleo` is the imported program that declares (or re-exports) the interface. This must be a static import.
169165
- `Interface` is the interface name.
170-
- `target` is an `identifier` value resolved at runtime — the name of the program to call into.
166+
- `target` is an `identifier` value (or `field`) resolved at runtime — the name of the program to call into.
171167
- `method` is the function to invoke.
172168

173169
### The `identifier` Type
@@ -176,15 +172,15 @@ The `identifier` type represents a program name resolved at runtime. An `identif
176172

177173
```leo
178174
let target: identifier = 'my_program';
179-
return token_a.aleo::TokenStandard@(target)::transfer_public(to, amount);
175+
return TokenStandard@(target)::transfer_public(to, amount);
180176
```
181177

182178
By default the target is looked up on the `aleo` network. To specify a different network explicitly, pass a second `identifier` as a second argument:
183179

184180
```leo
185181
let target: identifier = 'my_program';
186182
let network: identifier = 'aleo';
187-
return token_a.aleo::TokenStandard@(target, network)::transfer_public(to, amount);
183+
return TokenStandard@(target, network)::transfer_public(to, amount);
188184
```
189185

190186
:::note

documentation/language/programs_in_practice/public_storage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ program map.aleo {
7474
let current_value: u64 = balance.get_or_use(addr, 0u64);
7575
balance.set(addr, current_value + 1u64);
7676
77-
let next_current_value = balance.get(addr);
78-
balance.set(addr, current_value + 1u64);
77+
let next_current_value: u64 = balance.get(addr);
78+
balance.set(addr, next_current_value + 1u64);
7979
};
8080
}
8181
}

0 commit comments

Comments
 (0)