frankpfenning / C0

C0 Language
4 stars 0 forks source link

Ternary expressions do not expand typedefs #54

Closed robsimmons closed 11 years ago

robsimmons commented 11 years ago

The following code does not typecheck in cc0 as of r268.

typedef int* elem;

elem g() {
  return alloc(int);
}

int main() {
  int* i = true ? g() : NULL;
  return 0;
}

Thanks to Ben Spinelli in 15-122 Spring 2013 for finding this one.

frankpfenning commented 11 years ago

It's not as simple as that: the bug occurs when one of side of a conditional has indeterminate type (only NULL) and the other side is a type definition. Curiously, the code was correct at some point (still available in a comment) and then was unfixed.

I'll change it back.

On Fri, Mar 29, 2013 at 6:25 PM, Robert J. Simmons <notifications@github.com

wrote:

The following code does not typecheck in cc0 as of r268.

typedef int* elem;

elem g() { return alloc(int); }

int main() { int* i = true ? g() : NULL; return 0; }

— Reply to this email directly or view it on GitHubhttps://github.com/frankpfenning/C0/issues/54 .

robsimmons commented 11 years ago

I suspect the change was so that it would give better errors, reporting 'int*' instead of 'elem'? On Mar 29, 2013 7:44 PM, "Frank Pfenning" notifications@github.com wrote:

It's not as simple as that: the bug occurs when one of side of a conditional has indeterminate type (only NULL) and the other side is a type definition. Curiously, the code was correct at some point (still available in a comment) and then was unfixed.

I'll change it back.

  • Frank

On Fri, Mar 29, 2013 at 6:25 PM, Robert J. Simmons < notifications@github.com

wrote:

The following code does not typecheck in cc0 as of r268.

typedef int* elem;

elem g() { return alloc(int); }

int main() { int* i = true ? g() : NULL; return 0; }

— Reply to this email directly or view it on GitHub< https://github.com/frankpfenning/C0/issues/54> .

— Reply to this email directly or view it on GitHubhttps://github.com/frankpfenning/C0/issues/54#issuecomment-15665813 .

frankpfenning commented 11 years ago

Possibly. In any case, fixed as of r298.