-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type alias node to semantic analyzer
- Loading branch information
Showing
6 changed files
with
153 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,7 @@ | ||
# Show me some examples of type aliasing in Python try to give examples for all | ||
|
||
# 1. Type aliasing for built-in types | ||
# 2. Type aliasing for user-defined types | ||
# 3. Type aliasing for generic types | ||
# 4. Type aliasing for generic types with type parameters | ||
# 5. Type aliasing for generic types with type parameters and constraints | ||
# 6. Type aliasing for generic types with type parameters and constraints and default values | ||
# 7. Type aliasing for generic types with type parameters and constraints and default values and type parameters | ||
# 8. Type aliasing for generic types with type parameters and constraints and default values and type parameters and constraints | ||
# 9. Type aliasing for generic types with type parameters and constraints and default values and type parameters and constraints and default values | ||
# 10. Type aliasing for generic types with type parameters and constraints and default values and type parameters and constraints and default values and type parameters | ||
# 11. Type aliasing for generic types with type parameters and constraints and default values and type parameters and constraints and default values and type parameters and constraints | ||
# 12. Type aliasing for generic types with type parameters and constraints and default values and type parameters and constraints and default values and type parameters and constraints and default values | ||
# 13. Type aliasing for generic types with type parameters and constraints and default values and type parameters and constraints and default values and type parameters and constraints and default values and type parameters | ||
# 14. Type aliasing for generic types with type parameters and constraints and default values and type parameters and constraints and default values and type parameters and constraints and default values and type parameters and constraints | ||
|
||
type Alias1 = int | ||
type Alias2 = str | ||
type Alias3 = float | ||
|
||
type AliasWithParams1[T] = T | ||
type AliasWithParams2[T] = T | ||
|
||
type AliasToAnotherAlias = Alias1 |
125 changes: 125 additions & 0 deletions
125
...estdata/output/enderpy_python_type_checker__build__tests__symbol_table@type_alias.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
--- | ||
source: typechecker/src/build.rs | ||
description: "# Show me some examples of type aliasing in Python try to give examples for all\n\ntype Alias1 = int\ntype Alias2 = str\ntype Alias3 = float\n\ntype AliasToAnotherAlias = Alias1\n" | ||
expression: result | ||
input_file: typechecker/test_data/inputs/symbol_table/type_alias.py | ||
--- | ||
------------------- | ||
global scope: | ||
Symbols: | ||
Alias1 | ||
- Declarations: | ||
--: TypeAlias { | ||
declaration_path: DeclarationPath { | ||
module_name: [REDACTED]", | ||
node: Node { | ||
start: 81, | ||
end: 98, | ||
}, | ||
}, | ||
type_alias_node: TypeAlias { | ||
node: Node { | ||
start: 81, | ||
end: 98, | ||
}, | ||
name: "Alias1", | ||
type_params: [], | ||
value: Name( | ||
Name { | ||
node: Node { | ||
start: 95, | ||
end: 98, | ||
}, | ||
id: "int", | ||
}, | ||
), | ||
}, | ||
} | ||
Alias2 | ||
- Declarations: | ||
--: TypeAlias { | ||
declaration_path: DeclarationPath { | ||
module_name: [REDACTED]", | ||
node: Node { | ||
start: 99, | ||
end: 116, | ||
}, | ||
}, | ||
type_alias_node: TypeAlias { | ||
node: Node { | ||
start: 99, | ||
end: 116, | ||
}, | ||
name: "Alias2", | ||
type_params: [], | ||
value: Name( | ||
Name { | ||
node: Node { | ||
start: 113, | ||
end: 116, | ||
}, | ||
id: "str", | ||
}, | ||
), | ||
}, | ||
} | ||
Alias3 | ||
- Declarations: | ||
--: TypeAlias { | ||
declaration_path: DeclarationPath { | ||
module_name: [REDACTED]", | ||
node: Node { | ||
start: 117, | ||
end: 136, | ||
}, | ||
}, | ||
type_alias_node: TypeAlias { | ||
node: Node { | ||
start: 117, | ||
end: 136, | ||
}, | ||
name: "Alias3", | ||
type_params: [], | ||
value: Name( | ||
Name { | ||
node: Node { | ||
start: 131, | ||
end: 136, | ||
}, | ||
id: "float", | ||
}, | ||
), | ||
}, | ||
} | ||
AliasToAnotherAlias | ||
- Declarations: | ||
--: TypeAlias { | ||
declaration_path: DeclarationPath { | ||
module_name: [REDACTED]", | ||
node: Node { | ||
start: 138, | ||
end: 171, | ||
}, | ||
}, | ||
type_alias_node: TypeAlias { | ||
node: Node { | ||
start: 138, | ||
end: 171, | ||
}, | ||
name: "AliasToAnotherAlias", | ||
type_params: [], | ||
value: Name( | ||
Name { | ||
node: Node { | ||
start: 165, | ||
end: 171, | ||
}, | ||
id: "Alias1", | ||
}, | ||
), | ||
}, | ||
} | ||
|
||
all scopes: | ||
------------------- | ||
|