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

Type Tests against Open Records #30

Open
DavePearce opened this issue Jul 19, 2019 · 0 comments
Open

Type Tests against Open Records #30

DavePearce opened this issue Jul 19, 2019 · 0 comments

Comments

@DavePearce
Copy link
Member

There is currently a bug related to type testing against open records. The following from OpenRecord_Valid_4 illustrates:


type OpenRecord is {int x, ...}

function getField(OpenRecord r) -> int:
    if r is {int x}:
        return r.x
    else:
        if r is {int y, int x}:
            return r.x + r.y
        else:
            return -r.x

This is translated as:

function OpenRecord_Valid_4$getField$Q10OpenRecord(r) {
   if(is$Q10OpenRecordr1I1x(r))  {
      return r.x;
   } else  { ... }
}
function is$Q10OpenRecordr1I1x(v) {
   if(((typeof v.x) === "undefined") || ((typeof v.x) !== "number"))  {
      return false;
   }
   return true;
}

We can see that the test is not sufficient because it's not checking the number of fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant