Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capitalizes the primitive types #46

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/cli/tests/check/arg_count_mismatch.nemo
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fn func(x : i32) -> i32 {
fn func(x : I32) -> I32 {
x
}

fn main() -> i32 {
fn main() -> I32 {
func(1, 2, 3);
i32_rem_s(1, 2, 3);
}
2 changes: 1 addition & 1 deletion crates/cli/tests/check/cant_infer_lambda.nemo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main() -> i32 {
fn main() -> I32 {
let clos = \(z) { z };
clos(1)
}
4 changes: 2 additions & 2 deletions crates/cli/tests/check/cant_instantiate_function_ref.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn id[a](x : a) -> a {
x
}

fn main() -> i32 {
fn main() -> I32 {
let my_id = id;
my_id#[i32](10)
my_id#[I32](10)
}
4 changes: 2 additions & 2 deletions crates/cli/tests/check/field_type_mismatch.nemo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
struct F {
x : i32
x : I32
}

fn main() {
F { x = true }
}
}
10 changes: 5 additions & 5 deletions crates/cli/tests/check/lambda.nemo
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
fn main() -> i32 {
let f = \() -> i32 {
fn main() -> I32 {
let f = \() -> I32 {
return 10.0;
};
let wrong_return : fn (i32) -> i32 = \(x) {
let wrong_return : fn (I32) -> I32 = \(x) {
x
};
let wrong_param : fn (i32) -> i32 = \(x : f32) {
let wrong_param : fn (I32) -> I32 = \(x : F32) {
return x + 1.0;
};
let wrong_param_count : fn (i32) -> i32 = \(x, y) {
let wrong_param_count : fn (I32) -> I32 = \(x, y) {
return x + y;
};
return 42;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/check/missing_field.nemo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
struct F {
x : i32
x : I32
}

fn main() -> F {
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/check/non_function_import.nemo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import internal : i32 from external
import internal : I32 from external
2 changes: 1 addition & 1 deletion crates/cli/tests/check/operator_type_mismatch.nemo
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn main() -> i32 {
fn main() -> I32 {
1 + 2.0
}
4 changes: 2 additions & 2 deletions crates/cli/tests/check/return_type_mismatch.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ fn main() {
return 1
}

fn func() -> i32 {
fn func() -> I32 {
return {}
}
}
12 changes: 6 additions & 6 deletions crates/cli/tests/check/ty_arg_count_mismatch.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ variant List[a] {
struct Nil {}
}

fn main() -> i32 {
let x : Box = Box#[i32, i32]{ a = 1, b = 2 };
let x : Box[i32] = Box#[i32, i32]{ a = 1, b = 2 };
func#[i32](3);
Box#[i32] { a = 1, b = 2 };
List::Nil#[i32, f32] {};
fn main() -> I32 {
let x : Box = Box#[I32, I32]{ a = 1, b = 2 };
let x : Box[I32] = Box#[I32, I32]{ a = 1, b = 2 };
func#[I32](3);
Box#[I32] { a = 1, b = 2 };
List::Nil#[I32, Bool] {};
10
}
4 changes: 2 additions & 2 deletions crates/cli/tests/check/type_mismatch.nemo
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
global x : i32 = 10.0
global my_fn : fn (i32) -> i32 = \(x : f32) -> f32 { x }
global x : I32 = 10.0
global my_fn : fn (I32) -> I32 = \(x : F32) -> F32 { x }
2 changes: 1 addition & 1 deletion crates/cli/tests/check/unknown_field.nemo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
struct F {
x : i32
x : I32
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/tests/run/arithmetic.nemo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import log : fn (i32) -> unit from log
import log_f32 : fn (f32) -> unit from log
import log : fn (I32) -> Unit from log
import log_f32 : fn (F32) -> Unit from log

fn main() {
log(1 + 1);
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/tests/run/arrays.nemo
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import log : fn (i32) -> unit from log
import log : fn (I32) -> Unit from log

fn main() {
let empty: [i32] = [];
let empty: [I32] = [];
let single = [1];
let double = [1, 2];
let double_trailing = [1, 2,];

let nested : [[i32]] = [[], [42]];
let nested : [[I32]] = [[], [42]];
log(nested[1][0]);
log([1][0]);
}
2 changes: 1 addition & 1 deletion crates/cli/tests/run/block.nemo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import log : fn (i32) -> unit from log
import log : fn (I32) -> Unit from log

fn main() {
let x = { 1 };
Expand Down
14 changes: 7 additions & 7 deletions crates/cli/tests/run/closures.nemo
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import log : fn (i32) -> unit from log
import log : fn (I32) -> Unit from log

fn inferred() -> i32 {
let f : fn (i32, f32) -> i32 = \(x, y) { x + 2 };
fn inferred() -> I32 {
let f : fn (I32, F32) -> I32 = \(x, y) { x + 2 };
f(1, 2.0)
}

fn main() {
let x = (\(x : i32) -> i32 { x + 1 })(10);
let x = (\(x : I32) -> I32 { x + 1 })(10);
log(x);

let twice = \(f : fn (i32) -> i32) -> fn(i32) -> i32 {
\(x : i32) -> i32 {
let twice = \(f : fn (I32) -> I32) -> fn(I32) -> I32 {
\(x : I32) -> I32 {
f(f(x))
}
};
let add1 = \(x : i32) -> i32 { x + 1 };
let add1 = \(x : I32) -> I32 { x + 1 };
log(twice(add1)(3));
log(inferred());
}
10 changes: 5 additions & 5 deletions crates/cli/tests/run/decl.nemo
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import log : fn (i32) -> unit from log
import log : fn (I32) -> Unit from log

struct Point {
x : i32,
xs : [i32],
x : I32,
xs : [I32],
}

fn main() {
let x = 1;
let y : i32 = 10;
let y : I32 = 10;
set x = 1;
let xs = [1];
set xs[0] = 1;
Expand All @@ -20,7 +20,7 @@ fn main() {
log(p.xs[0]);

let i = 0;
while i < array_len#[i32](p.xs) {
while i < array_len#[I32](p.xs) {
log(p.xs[i]);
set i = i + 1;
}
Expand Down
12 changes: 6 additions & 6 deletions crates/cli/tests/run/expr_postfix.nemo
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import log : fn(i32) -> unit from log
import log : fn(I32) -> Unit from log

fn f0() {
log(42);
}

fn f1(x : i32) {
fn f1(x : I32) {
log(x);
}

fn f2(x : i32, y : i32) {
fn f2(x : I32, y : I32) {
log(x);
log(y);
}

fn ff(x : i32) -> fn(i32) -> unit {
\(y : i32) {
fn ff(x : I32) -> fn(I32) -> Unit {
\(y : I32) {
log(y)
}
}

struct S {
f0 : fn() -> unit,
f0 : fn() -> Unit,
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/run/if.nemo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import log : fn (i32) -> unit from log
import log : fn (I32) -> Unit from log

fn main() {
if true { log(1) } else { log(2) };
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/tests/run/infix_op.nemo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import log : fn (i32) -> unit from log
import log : fn (I32) -> Unit from log

struct S { x : i32 }
struct S { x : I32 }

fn main() {
log(1 + 1);
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/tests/run/literals.nemo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import log : fn (i32) -> unit from log
import logb : fn (bool) -> unit from log
import logf : fn (f32) -> unit from log
import log : fn (I32) -> Unit from log
import logb : fn (Bool) -> Unit from log
import logf : fn (F32) -> Unit from log

fn main() {
log(0);
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/tests/run/modules/dep.nemo
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module dep
exports (S, V, f, log)

import log : fn (i32) -> unit from log
import log : fn (I32) -> Unit from log

struct S {
x : i32,
x : I32,
}

variant V {
struct S { y : i32 },
struct S { y : I32 },
}

fn f(s : S, x : i32) {
fn f(s : S, x : I32) {
set s.x = s.x + x;
}
2 changes: 1 addition & 1 deletion crates/cli/tests/run/modules/main.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exports (main)

use dep

import log : fn (i32) -> unit from log
import log : fn (I32) -> Unit from log

fn main() {
let s : dep::S = dep::S { x = 10 };
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/tests/run/poly.nemo
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
fn poly[a, b](a : a, other : b) {
poly#[i32, bool](1, true)
poly#[I32, Bool](1, true)
}

struct Box[a] {
content : a
}

fn main() -> Box[i32] {
Box #[i32] { content = 42 }
fn main() -> Box[I32] {
Box #[I32] { content = 42 }
}
14 changes: 7 additions & 7 deletions crates/cli/tests/run/return.nemo
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import log : fn (i32) -> unit from log
import logf : fn (f32) -> unit from log
import log : fn (I32) -> Unit from log
import logf : fn (F32) -> Unit from log

fn main() -> i32 {
fn main() -> I32 {
log(early_return());
logf(loop_return());
log(lambda_return());
}

fn early_return() -> i32 {
fn early_return() -> I32 {
return 10;
20;
}

fn loop_return() -> f32 {
fn loop_return() -> F32 {
let i = 0.0;
while true {
if i > 10.0 {
Expand All @@ -23,8 +23,8 @@ fn loop_return() -> f32 {
0.0;
}

fn lambda_return() -> i32 {
let f = \() -> bool {
fn lambda_return() -> I32 {
let f = \() -> Bool {
return true;
};
if f() {
Expand Down
10 changes: 5 additions & 5 deletions crates/cli/tests/run/structs.nemo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import log : fn(i32) -> unit from log
import log : fn(I32) -> Unit from log

struct BoxInt { x : i32 }
struct BoxInt { x : I32 }
struct Box[a] { x : a }

struct NestedInt { x : BoxInt }
Expand All @@ -11,18 +11,18 @@ variant Option[a] {
struct Some { val : a },
}
// Rec is just a non-empty linked list
struct RecInt { head : i32, tail : Option[RecInt] }
struct RecInt { head : I32, tail : Option[RecInt] }
struct Rec[a] { head : a, tail : Option[Rec[a]] }

fn for_reci(r : RecInt, f : fn(i32) -> unit) {
fn for_reci(r : RecInt, f : fn(I32) -> Unit) {
f(r.head);
match r.tail {
Option::None _ => {},
Option::Some t => { for_reci(t.val, f) },
}
}

fn for_rec[a](r : Rec[a], f : fn(a) -> unit) {
fn for_rec[a](r : Rec[a], f : fn(a) -> Unit) {
f(r.head);
match r.tail {
Option::None _ => {},
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/tests/run/variants.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ variant Enum {
}

variant Shape {
struct Circle { radius : f32 },
struct Rectangle { len : f32, width : f32 },
struct Circle { radius : F32 },
struct Rectangle { len : F32, width : F32 },
}

import print_char : fn (i32) -> unit from print_char
import logf : fn (f32) -> unit from log
import print_char : fn (I32) -> Unit from print_char
import logf : fn (F32) -> Unit from log

fn print_enum(e : Enum) {
let c = match e {
Expand Down
2 changes: 2 additions & 0 deletions crates/cli/tests/snapshots/check@arg_count_mismatch.nemo.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ info:
args:
- check
- tests/check/arg_count_mismatch.nemo
env:
RUST_BACKTRACE: "0"
input_file: crates/cli/tests/check/arg_count_mismatch.nemo
---
success: false
Expand Down
Loading