~mna/snow

295abd9ad835316d87174a3b29f5ed942f25aa67 — Martin Angers 1 year, 8 months ago 76e9ce9
pkg/semantic: add simple generic struct test
M pkg/codegen/testdata/fn_nested_generic_fn.snow.want => pkg/codegen/testdata/fn_nested_generic_fn.snow.want +12 -12
@@ 12,12 12,12 @@ func _اcall(
}

func _اouter() {
	var innerا2 func(
		w bool,
	) bool
	innerا2 = func(
		w bool,
	) bool {
	var innerا0 func(
		w int,
	) int
	innerا0 = func(
		w int,
	) int {
		return w
	}
	var innerا1 func(


@@ 28,12 28,12 @@ func _اouter() {
	) string {
		return w
	}
	var innerا0 func(
		w int,
	) int
	innerا0 = func(
		w int,
	) int {
	var innerا2 func(
		w bool,
	) bool
	innerا2 = func(
		w bool,
	) bool {
		return w
	}
	var _ int = innerا0(1)

A pkg/semantic/testdata/check/struct_simple_generic.snow.err => pkg/semantic/testdata/check/struct_simple_generic.snow.err +0 -0
A pkg/semantic/testdata/check/struct_simple_generic.snow.want => pkg/semantic/testdata/check/struct_simple_generic.snow.want +26 -0
@@ 0,0 1,26 @@
file testdata/struct_simple_generic.snow [0, 2, 1]
  fn main [let: () -> void]
    block [2]
      let= a [let: struct A[int]]
        call [x] [1] [value: struct A[int]]
          generic inst [1] [type: struct A[int]]
            ident A [type: struct A]
            ident int [type: int]
          int [1] [const: int]
      expr
        call [1] [value: void]
          ident println [let: (int) -> void]
          select [let: int]
            ident a [let: struct A[int]]
            ident x [var: int]
  fn println [let: (int) -> void]
    @ [import, symbol] [2] [value: struct extern]
      ident extern [type: struct extern]
      string ["fmt"] [const: string]
      string ["Println"] [const: string]
    let: i [let: int]
      ident int [type: int]
  struct A [1, 0, 0, $1] [type: struct A]
    generic type $T [type: $T]
    var: x [var: $T]
      ident $T [type: $T]

A pkg/semantic/testdata/scopes/struct_simple_generic.snow.err => pkg/semantic/testdata/scopes/struct_simple_generic.snow.err +0 -0
A pkg/semantic/testdata/scopes/struct_simple_generic.snow.want => pkg/semantic/testdata/scopes/struct_simple_generic.snow.want +41 -0
@@ 0,0 1,41 @@
1 *semantic.Unit {
.  bool
.  extern
.  f32
.  f64
.  false
.  float
.  i16
.  i32
.  i64
.  i8
.  int
.  string
.  true
.  u16
.  u32
.  u64
.  u8
.  uint
.  void
.  2 *semantic.Struct {
.  .  import
.  .  pkg
.  .  symbol
.  }
.  3 *semantic.File {
.  .  A
.  .  main
.  .  println
.  .  4 *semantic.Struct {
.  .  .  $T
.  .  .  x
.  .  }
.  .  5 *semantic.Fn {
.  .  .  a
.  .  }
.  .  6 *semantic.Fn {
.  .  .  i
.  .  }
.  }
}

A pkg/semantic/testdata/static/struct_simple_generic.snow.err => pkg/semantic/testdata/static/struct_simple_generic.snow.err +0 -0
A pkg/semantic/testdata/static/struct_simple_generic.snow.want => pkg/semantic/testdata/static/struct_simple_generic.snow.want +5 -0
@@ 0,0 1,5 @@
testdata/struct_simple_generic.snow:6:11: A
testdata/struct_simple_generic.snow:6:13: int
testdata/struct_simple_generic.snow:7:3: println
testdata/struct_simple_generic.snow:7:11: a
testdata/struct_simple_generic.snow:7:13: x

A pkg/semantic/testdata/struct_simple_generic.snow => pkg/semantic/testdata/struct_simple_generic.snow +13 -0
@@ 0,0 1,13 @@
struct A[$T] {
  var x: $T
}

fn main() {
  let a = A[int](x: 1)
  println(a.x)
}

@extern(import: "fmt", symbol: "Println")
fn println(i: int)

#=1

A pkg/semantic/testdata/types/struct_simple_generic.snow.err => pkg/semantic/testdata/types/struct_simple_generic.snow.err +0 -0
A pkg/semantic/testdata/types/struct_simple_generic.snow.want => pkg/semantic/testdata/types/struct_simple_generic.snow.want +26 -0
@@ 0,0 1,26 @@
file testdata/struct_simple_generic.snow [0, 2, 1]
  fn main [let: () -> void]
    block [2]
      let= a [let: struct A[int]]
        call [x] [1] [value: struct A[int]]
          generic inst [1] [type: struct A[int]]
            ident A [type: struct A]
            ident int [type: int]
          int [1] [const: int]
      expr
        call [1] [value: void]
          ident println [let: (int) -> void]
          select [let: int]
            ident a [let: struct A[int]]
            ident x [var: int]
  fn println [let: (int) -> void]
    @ [import, symbol] [2] [value: struct extern]
      ident extern [type: struct extern]
      string ["fmt"] [const: string]
      string ["Println"] [const: string]
    let: i [let: int]
      ident int [type: int]
  struct A [1, 0, 0, $1] [type: struct A]
    generic type $T [type: $T]
    var: x [var: $T]
      ident $T [type: $T]