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

Detect cycles in exceptions #60

Closed
denismerigoux opened this issue Jan 8, 2021 · 2 comments
Closed

Detect cycles in exceptions #60

denismerigoux opened this issue Jan 8, 2021 · 2 comments
Labels
🔧 compiler Issue concerns the compiler ❓ invalid This doesn't seem right

Comments

@denismerigoux
Copy link
Contributor

Right now the algorithm that builds the default tree from the list of rules defining a variable expects that there are no cycles in the label and exception declaration.

(** Transforms a flat list of rules into a tree, taking into account the priorities declared between
rules
{e Invariant:} there are no exceptions cycles
{e Invariant:} there are no dandling exception pointers in the rules *)
let rec def_map_to_tree (def_info : Ast.ScopeDef.t)
(is_def_func : Scopelang.Ast.typ Pos.marked option) (def : Ast.rule Ast.RuleMap.t) :
rule_tree list =

This requirement is not enforced, so we should built a dependency graph whose vertices are label and edges are exception, and check for cycles in this graph for each scope variable (defined by a list of rules).

The code for this graph checking could live in src/catala/desugared/dependency.ml.

@denismerigoux denismerigoux added ❓ invalid This doesn't seem right 🔧 compiler Issue concerns the compiler labels Jan 8, 2021
@denismerigoux
Copy link
Contributor Author

When fixing this issue, test it on this case:

@Test@
/*
new scope A:
param x content int
scope A:
label base_x
exception exception_exception_x
def x := 0
label exception_x
exception base_x
def x := 1
label exception_exception_x
exception exception_x
def x := 2
*/

@denismerigoux
Copy link
Contributor Author

Fixed by 6787d5b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 compiler Issue concerns the compiler ❓ invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant