source: tests/bugs/7.cfa

Last change on this file was fd54fef, checked in by Michael Brooks <mlbrooks@…>, 3 years ago

Converting the project to use the new syntax for otype, dtype and ttytpe.

Changed prelude (gen), libcfa and test suite to use it. Added a simple deprecation rule of the old syntax to the parser; we might wish to support both syntaxes "officially," like with an extra CLI switch, but this measure should serve as a simple reminder for our team to try the new syntax.

  • Property mode set to 100644
File size: 627 bytes
RevLine 
[4d23dd2]1// Trac ticket
2// https://cforall.uwaterloo.ca/trac/ticket/7
3
4#include <stdlib.hfa>
5extern "C" {
6#include <stdbool.h>
7}
8
9// (Bug 1 unresolved as of this test.)
[fd54fef]10forall(T)
[4d23dd2]11struct stack_node;
12
[fd54fef]13forall(T)
[4d23dd2]14struct stack_node {
15    stack_node(T) * next;
16    T item;
17};
18
[fd54fef]19forall(T)
[4d23dd2]20struct stack {
21    stack_node(T) * head;
22};
23
[fd54fef]24trait stack_errors(T) {
[4d23dd2]25    T emptyStackHandler (stack(T) * this);
26};
27
[fd54fef]28forall(T | stack_errors(T))
[4d23dd2]29T pop (stack(T) * this) {
30    return (T){};
31}
32
33int emptyStackHandler (stack(int) * this) {
34    return 0;
35}
36
37int main (int argc, char * argv[]) {
38    stack(int) stackOfInts;
39    pop(&stackOfInts);
40    return 0;
41}
Note: See TracBrowser for help on using the repository browser.