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

Cannot track side effects in tupled for loop #107

Open
fredokun opened this issue Dec 2, 2019 · 1 comment
Open

Cannot track side effects in tupled for loop #107

fredokun opened this issue Dec 2, 2019 · 1 comment

Comments

@fredokun
Copy link
Collaborator

fredokun commented Dec 2, 2019

The following program yields a fatal error :

def f(L):
    """ list[tuple[str, int]] -> int """
    # s : str
    # k : int
    s,k = L[0]
    for u,v in L[1:]:
        if v > k:
            k = v
    return k

The problem is in the for u, v in L[1:]: bit ...
and the error raised is the following one:

Traceback (most recent call last):
  ...
  File "../mrpython/typechecking/typechecker.py", line 328, in type_check_FunctionDef
    instr.type_check(ctx)
  File "../mrpython/typechecking/typechecker.py", line 596, in type_check_For
    for_node.side_effect(ctx)
  File "../mrpython/typechecking/side_effects_utils.py", line 279, in side_effect_For
    
  File "../mrpython/typechecking/side_effects_utils.py", line 267, in assign_extended
    linearize(ctx, working_var, aliases)
  File "../mrpython/typechecking/side_effects_utils.py", line 250, in linearize
    tmp.access(str(i))
  File "../mrpython/typechecking/side_effects_utils.py", line 41, in access
    if c != p:
NotImplementedError: error in side-effect-checking, please report
@fredokun fredokun added the bug label Dec 2, 2019
@fredokun
Copy link
Collaborator Author

fredokun commented Dec 2, 2019

This is somewhat fixed in f2c0c64

However, I think aliasing with tuples should be done as follows:

for <var1>, <var2>, ...,  <varN> in  <iterable>:
   <body>

should be handled like :

for <dynvar> in  <iterable>:
   <var1>, <var2>, ...,  <varN> = <dynvar>
   <body>

Where <dynvar> is a gensym used only for the aliasing datastructure.

@fredokun fredokun added enhancement and removed bug labels Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant