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

DFLang contains invalid redefinition of variable #37

Open
Feliix42 opened this issue May 3, 2019 · 0 comments
Open

DFLang contains invalid redefinition of variable #37

Feliix42 opened this issue May 3, 2019 · 0 comments
Labels

Comments

@Feliix42
Copy link
Member

Feliix42 commented May 3, 2019

The following piece of code uses recursion to emulate a loop that keeps some local state (the maze):

ns some_ns;

use sf crate::{is_not_empty, splitup, join, insert_path, get_one, add_to, empty_vec};
use sf labyrinth::grid::update_maze;
use sf labyrinth::pathfinder::find_path;

fn main(maze: Maze, to_map: Vec<(Point, Point)>) -> Maze {
    transact(maze, to_map)
}

fn search_path(maze: Maze, to_map: Vec<(Point, Point)>, mapped: Vec<Option<Path>>) -> Vec<Option<Path>> {
    let (pair, tail) = get_one(to_map);
    let p = find_path(maze, pair);
    let updated = insert_path(p, maze);
    let new_mapped = add_to(mapped, p);

    if (is_not_empty(tail)) {
        search_path(updated, tail, new_mapped)
    } else {
        new_mapped
    }
}

fn transact(maze: Maze, to_map: Vec<(Point, Point)>) -> Maze {
    let (tm1, tm2) = splitup(to_map);

    let part1 = search_path(maze, tm1, empty_vec());
    let part2 = search_path(maze, tm2, empty_vec());

    let paths = join(part1, part2);

    let (remap_paths, new_maze) = update_maze(maze, paths);

    // simple check for len == 0
    if (is_not_empty(remap_paths)) {
        transact(new_maze, remap_paths)
    } else {
        new_maze
    }
}

When compiling it using the latest version of both ohuac and ohua-core, I receive the following error, indicating that an error occured during dflang generation:

[Error] Rebinding of Binding "j"
CallStack (from HasCallStack):
  throwErrorS, called at src/Ohua/Util.hs:225:20 in ohua-core-0.3.0-96ePW2cHQzLLYHDgUMVZet:Ohua.Util
  throwErrorDebugS, called at src/Ohua/Monad.hs:43:12 in ohua-core-0.3.0-96ePW2cHQzLLYHDgUMVZet:Ohua.Monad
  failWith, called at src/Ohua/DFLang/Passes.hs:58:23 in ohua-core-0.3.0-96ePW2cHQzLLYHDgUMVZet:Ohua.DFLang.Passes

[alang-core] - [alang-resolved] - [dflang-core]

@Feliix42 Feliix42 added the bug label May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant