Skip to content

Commit e20dcda

Browse files
committed
Resolve Issue: Merge equal cases into 1
1 parent 55a11a1 commit e20dcda

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Diff for: text/0004-type-deduction.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,21 @@ The variable must be of type String.
109109

110110

111111
## Correct Inference for dependencies
112-
Extra care has to be taken when deducing in binary expressions, with an Operator (like Plus, Minus, Multiply, Divide, In (var on lhs), NotIn (var on lhs)) where the variable type depends on the type of the other side. There are 2 special cases that have to be handled.
112+
Extra care has to be taken when deducing in binary expressions, with an Operator (like Plus, Minus, Multiply, Divide, In (var on lhs), NotIn (var on lhs)) where the variable type depends on the type of the other side.
113113

114-
### Special case 1: Binary with variables on both sides
115-
```shell Example
114+
```shell Variables on both sides
116115
ls | where size < $a * $b; kill $a
117116
$a -> SyntaxShape::Int
118117
$b -> SyntaxShape::Unit
119118
```
120-
121-
At the time of traversing the AST, any deduction for any variable may not be present, and if present may not be complete. Therefore constellations in which the deduction of one variable depends on the deduction of another one (we will call these constellations 'dependencies'), have to be postponed.
122-
123-
### Special case 2: Binary which depends on the result type of another expression
124-
```shell Example
119+
```shell Variable on one side, math expression with variables on other
125120
ls | where size < $a * ($b * $c); kill $b $c
126121
$a -> SyntaxShape::Unit
127122
$b -> SyntaxShape::Int
128123
$c -> SyntaxShape::Int
129124
```
130-
Same as above. But this time $a also depends on the result type of ($b * $c). This dependency has to be postponed, as $b nor $c can be deduced at the point in time of traversing the AST.
131125

126+
At the time of traversing the AST, any deduction for any variable may not be present, and if present may not be complete. Therefore constellations in which the deduction of one variable depends on the deduction of another one (we will call these constellations 'dependencies'), have to be postponed.
132127

133128
As soon as the AST is traversed, the dependencies have to be resolved.
134129
Please note: One might think of a dependency as a edge in a directed graph, with variables as nodes. Every Node with no outgoing edge is completly deduced. Every Node with an edge towards such a completly deduced node can then be inferred. Nodes with cycles (e.G. `ls | where size < $a * $b` $a depends on $b, $b depends on $a) can't be deduced completly.

0 commit comments

Comments
 (0)