harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

33-yield.ha (434B)


      1 fn basics() void = {
      2 	let x = {
      3 		yield 10;
      4 	};
      5 	let y = :outer {
      6 		if (true) {
      7 			yield :outer, 20;
      8 		};
      9 		abort();
     10 	};
     11 	assert(x == 10);
     12 	assert(y == 20);
     13 };
     14 
     15 fn termination() void = {
     16 	:outer {
     17 		if (true) {
     18 			yield :outer;
     19 		} else void;
     20 		abort();
     21 	};
     22 };
     23 
     24 fn cast_lowering() void = {
     25 	let x: (int | void) = {
     26 		yield 10;
     27 	};
     28 	assert(x as int == 10);
     29 };
     30 
     31 export fn main() void = {
     32 	basics();
     33 	termination();
     34 	cast_lowering();
     35 };