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

function signature and dispatch behavior #136

Closed
pafnucy opened this issue Jan 26, 2017 · 1 comment
Closed

function signature and dispatch behavior #136

pafnucy opened this issue Jan 26, 2017 · 1 comment

Comments

@pafnucy
Copy link

pafnucy commented Jan 26, 2017

At the moment, function return value signature isn't checked and serves as semantic annotation for reader, function with declared value of 1 or 2 might return 4. Also there is a less important issue with function dispatch. In example below, f1 for var ints doesn't get called with var x as argument.

var int: x;
set of int: DAY = 1..7;
constraint x in {5, 6};

function array[1..2] of 1..2: f1(int: n) = [i | i in 1..n];
function array[1..2] of var 1..2: f1(var int: n) = [1, 2, 3, 4];
function set of DAY: f2() = {10};
function set of 1..2: f3() = {10};

output[show(f1(3)) ++ "\n" ++ show(f1(x)) ++ "\n" ++ show(f2()) ++ "\n" ++ show(f3())];
solve satisfy;

Code runs, returning

[1, 2, 3]
[1, 2, 3, 4, 5, 6]
10..10
10..10

I think the code should rather fail and in case of

function array[int] of int: f1(int: n) = [i | i in 1..n];
function array[int] of var int: f1(var int: n) = [1, 2, 3, 4];

first two lines of output should be

[1, 2, 3]
[1, 2, 3, 4]
guidotack added a commit that referenced this issue Jan 29, 2017
guidotack added a commit that referenced this issue Jan 31, 2017
@guidotack
Copy link
Member

Thanks, this should be mostly fixed now in the develop branch.

guidotack added a commit that referenced this issue Feb 6, 2017
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

2 participants