2024-04-05 15:32:34 +03:00
|
|
|
This test exposes a name clash between the scope function (`ScopeName,`
|
|
|
|
rewritten to `scope_name`) and the scope variable `scope_name`.
|
|
|
|
|
|
|
|
```catala
|
2024-04-05 16:25:46 +03:00
|
|
|
declaration scope SomeNâme:
|
2024-04-05 15:32:34 +03:00
|
|
|
input i content integer
|
|
|
|
output o content integer
|
|
|
|
|
2024-04-05 16:25:46 +03:00
|
|
|
scope SomeNâme:
|
2024-04-05 15:32:34 +03:00
|
|
|
definition o equals i + 1
|
|
|
|
|
|
|
|
declaration scope B:
|
2024-04-05 16:25:46 +03:00
|
|
|
output some_nâme scope SomeNâme
|
2024-04-05 15:32:34 +03:00
|
|
|
|
|
|
|
scope B:
|
2024-04-05 16:25:46 +03:00
|
|
|
definition some_nâme.i equals 1
|
2024-04-05 15:32:34 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
```catala-test-inline
|
|
|
|
$ catala python
|
|
|
|
# This file has been generated by the Catala compiler, do not edit!
|
|
|
|
|
|
|
|
from catala.runtime import *
|
|
|
|
from typing import Any, List, Callable, Tuple
|
|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
class SomeName:
|
|
|
|
def __init__(self, o: Integer) -> None:
|
|
|
|
self.o = o
|
|
|
|
|
|
|
|
def __eq__(self, other: object) -> bool:
|
|
|
|
if isinstance(other, SomeName):
|
|
|
|
return (self.o == other.o)
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def __ne__(self, other: object) -> bool:
|
|
|
|
return not (self == other)
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return "SomeName(o={})".format(self.o)
|
|
|
|
|
|
|
|
class B:
|
|
|
|
def __init__(self, some_name: SomeName) -> None:
|
|
|
|
self.some_name = some_name
|
|
|
|
|
|
|
|
def __eq__(self, other: object) -> bool:
|
|
|
|
if isinstance(other, B):
|
|
|
|
return (self.some_name == other.some_name)
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def __ne__(self, other: object) -> bool:
|
|
|
|
return not (self == other)
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return "B(some_name={})".format(self.some_name)
|
|
|
|
|
|
|
|
class SomeNameIn:
|
|
|
|
def __init__(self, i_in: Integer) -> None:
|
|
|
|
self.i_in = i_in
|
|
|
|
|
|
|
|
def __eq__(self, other: object) -> bool:
|
|
|
|
if isinstance(other, SomeNameIn):
|
|
|
|
return (self.i_in == other.i_in)
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def __ne__(self, other: object) -> bool:
|
|
|
|
return not (self == other)
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return "SomeNameIn(i_in={})".format(self.i_in)
|
|
|
|
|
|
|
|
class BIn:
|
|
|
|
def __init__(self, ) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def __eq__(self, other: object) -> bool:
|
|
|
|
if isinstance(other, BIn):
|
|
|
|
return (True)
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def __ne__(self, other: object) -> bool:
|
|
|
|
return not (self == other)
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
return "BIn()".format()
|
|
|
|
|
|
|
|
|
|
|
|
def some_name(some_name_in:SomeNameIn):
|
|
|
|
i = some_name_in.i_in
|
|
|
|
try:
|
|
|
|
def temp_o(_:Unit):
|
2024-04-22 18:55:36 +03:00
|
|
|
def temp_o_1(_:Unit):
|
2024-04-05 15:32:34 +03:00
|
|
|
return True
|
2024-04-22 18:55:36 +03:00
|
|
|
def temp_o_2(_:Unit):
|
|
|
|
return (i + integer_of_string("1"))
|
2024-04-05 15:32:34 +03:00
|
|
|
return handle_default(SourcePosition(filename="tests/backends/python_name_clash.catala_en",
|
2024-04-30 18:48:02 +03:00
|
|
|
start_line=10, start_column=23,
|
|
|
|
end_line=10, end_column=28,
|
2024-04-22 18:55:36 +03:00
|
|
|
law_headings=[]), [], temp_o_1, temp_o_2)
|
|
|
|
def temp_o_3(_:Unit):
|
|
|
|
return False
|
|
|
|
def temp_o_4(_:Unit):
|
2024-04-26 19:31:26 +03:00
|
|
|
raise Empty
|
2024-04-05 15:32:34 +03:00
|
|
|
temp_o_5 = handle_default(SourcePosition(filename="tests/backends/python_name_clash.catala_en",
|
|
|
|
start_line=7, start_column=10,
|
|
|
|
end_line=7, end_column=11,
|
2024-04-22 18:55:36 +03:00
|
|
|
law_headings=[]), [temp_o], temp_o_3,
|
|
|
|
temp_o_4)
|
2024-04-26 19:31:26 +03:00
|
|
|
except Empty:
|
|
|
|
raise NoValue(SourcePosition(
|
|
|
|
filename="tests/backends/python_name_clash.catala_en",
|
|
|
|
start_line=7, start_column=10,
|
|
|
|
end_line=7, end_column=11, law_headings=[]))
|
2024-04-05 15:32:34 +03:00
|
|
|
o = temp_o_5
|
|
|
|
return SomeName(o = o)
|
|
|
|
|
|
|
|
def b(b_in:BIn):
|
|
|
|
try:
|
|
|
|
def temp_result(_:Unit):
|
2024-04-22 18:55:36 +03:00
|
|
|
def temp_result_1(_:Unit):
|
2024-04-05 15:32:34 +03:00
|
|
|
return True
|
2024-04-22 18:55:36 +03:00
|
|
|
def temp_result_2(_:Unit):
|
|
|
|
return integer_of_string("1")
|
2024-04-05 15:32:34 +03:00
|
|
|
return handle_default(SourcePosition(filename="tests/backends/python_name_clash.catala_en",
|
2024-04-30 18:48:02 +03:00
|
|
|
start_line=16, start_column=33,
|
|
|
|
end_line=16, end_column=34,
|
2024-04-22 18:55:36 +03:00
|
|
|
law_headings=[]), [], temp_result_1,
|
|
|
|
temp_result_2)
|
|
|
|
def temp_result_3(_:Unit):
|
|
|
|
return False
|
|
|
|
def temp_result_4(_:Unit):
|
2024-04-26 19:31:26 +03:00
|
|
|
raise Empty
|
2024-04-05 15:32:34 +03:00
|
|
|
temp_result_5 = handle_default(SourcePosition(filename="tests/backends/python_name_clash.catala_en",
|
|
|
|
start_line=16, start_column=14,
|
|
|
|
end_line=16, end_column=25,
|
2024-04-22 18:55:36 +03:00
|
|
|
law_headings=[]), [temp_result],
|
|
|
|
temp_result_3, temp_result_4)
|
2024-04-26 19:31:26 +03:00
|
|
|
except Empty:
|
|
|
|
raise NoValue(SourcePosition(
|
|
|
|
filename="tests/backends/python_name_clash.catala_en",
|
|
|
|
start_line=16, start_column=14,
|
|
|
|
end_line=16, end_column=25, law_headings=[]))
|
2024-04-05 15:32:34 +03:00
|
|
|
result = some_name(SomeNameIn(i_in = temp_result_5))
|
|
|
|
result_1 = SomeName(o = result.o)
|
|
|
|
if True:
|
|
|
|
temp_some_name = result_1
|
|
|
|
else:
|
|
|
|
temp_some_name = result_1
|
|
|
|
some_name_1 = temp_some_name
|
|
|
|
return B(some_name = some_name_1)
|
|
|
|
```
|
|
|
|
The above should *not* show `some_name = temp_some_name`, but instead `some_name_1 = ...`
|