Fix bug from small improvements
This commit is contained in:
@@ -65,8 +65,8 @@ Finally, just like `ast_case::typecheck` called
|
||||
|
||||
We follow the same implementation strategy for patterns,
|
||||
but we don't need indentation, or recursion:
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 114 116 >}}
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 122 127 >}}
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 115 117 >}}
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 123 128 >}}
|
||||
|
||||
In `main`, let's print the bodies of each function we receive from the parser:
|
||||
{{< codelines "C++" "compiler/04/main.cpp" 47 56 >}}
|
||||
@@ -160,12 +160,12 @@ we simply pass the type of the expression to be case analyzed into
|
||||
the pattern matching method. However, since we don't want
|
||||
case analysis on functions, we ensure that the type of the expression
|
||||
is `type_base`. If not, we report this:
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 100 102 >}}
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 107 110 >}}
|
||||
|
||||
The next exception is in `pattern_constr::match`. It occurs
|
||||
when the pattern has a constructor we don't recognize, and
|
||||
that's exactly what we report:
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 131 133 >}}
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 132 134 >}}
|
||||
|
||||
The next exception occurs in a loop, when we bind
|
||||
types for each of the constructor pattern's variables.
|
||||
@@ -174,7 +174,7 @@ constructor type to a `type_arr`. Conceptually,
|
||||
this means that the pattern wants to apply the
|
||||
constructor to more parameters than it actually
|
||||
takes:
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 137 137 >}}
|
||||
{{< codelines "C++" "compiler/04/ast.cpp" 138 138 >}}
|
||||
|
||||
We remove the last throw at the bottom of `pattern_constr::match`.
|
||||
This is because once unification succeeds, we know
|
||||
|
||||
Reference in New Issue
Block a user