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

Regent type mismatch error sometimes reports matching types #491

Open
TWarszawski opened this issue Feb 25, 2019 · 3 comments
Open

Regent type mismatch error sometimes reports matching types #491

TWarszawski opened this issue Feb 25, 2019 · 3 comments
Assignees
Labels
backlog Feature/fix that is desirable, but not currently planned enhancement Regent Issues pertaining to Regent

Comments

@TWarszawski
Copy link
Contributor

Sometimes the Regent compiler gives type mismatch errors where it reports two identical types. The example program below results in the error message: "type mismatch in assignment: expected region(ispace(int1d), int32) but got region(ispace(int1d), int32)". I've had several questions about similar examples from students during cs315b, and also since the class ended from those continuing to work with Regent. I believe one of those examples was due to a struct or field space being both imported and defined. I think that it could help alleviate confusion to give a more informative error message.

import "regent"
local c = regentlib.c
struct AStruct {
  ptr : region(ispace(int1d), int32),
}
task test(x : AStruct)
  x.ptr = region(ispace(int1d,100), int32)
end
@elliottslaughter
Copy link
Contributor

If you run with the flag -fdebug 1 you should see an error message like:

expected region#1(ispace#1(int1d), int32) but got region#2(ispace#2(int1d), int32)

Regions are not really always equal, and in general assignment to regions is not expected to work (it wouldn't be safe even if the index and field spaces match). In this particular case, since we're talking about a region relation, you can make this program type check by doing:

import "regent"

struct AStruct {
  r : region(ispace(int1d), int32),
}

task test(x : AStruct)
  x = AStruct { r = region(ispace(int1d,100), int32) }
end

But this wouldn't work for e.g. a region local variable r. Basically, there are cases were we're allowed to do special matching of regions (task calls, packing structs), but aside from that regions should always be considered to be incompatible with each other. Therefore, we could add logic to print the #1 and #2, but it wouldn't tell you why these particular regions weren't allowed to match. (E.g. in the original code the error was in the kind of statement used to assign the region, not in the regions themselves being incompatible per se.) So I'm not sure there are any easy changes that would really be that big of an improvement.

If you have any suggestions for how to improve the error messages, let me know.

@manopapad
Copy link
Contributor

How about adding an extra note to region incompatibility error messages, that covers the common case? Something like "Note that a reference to a region cannot be overriden/reseated". You could even do this only in cases where the two incompatible region types have the same index and field space.

@lightsighter lightsighter added the Regent Issues pertaining to Regent label Apr 23, 2019
@elliottslaughter elliottslaughter added the backlog Feature/fix that is desirable, but not currently planned label Sep 25, 2019
@elliottslaughter
Copy link
Contributor

This will be addressed in part when #583 merges, though there are still some issues blocking that merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Feature/fix that is desirable, but not currently planned enhancement Regent Issues pertaining to Regent
Projects
None yet
Development

No branches or pull requests

4 participants