mirror of
https://github.com/RoBaertschi/tt.git
synced 2025-04-16 05:53:30 +00:00
fixed some bugs
This commit is contained in:
parent
508b3fdc7a
commit
6425cd3b55
@ -173,9 +173,12 @@ func (be *BinaryExpression) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BlockExpression struct {
|
type BlockExpression struct {
|
||||||
Token token.Token // The '{'
|
Token token.Token // The '{'
|
||||||
Expressions []Expression
|
Expressions []Expression
|
||||||
ReturnExpression Expression // A expression that does not end with a semicolon, there can only be one of those and it hast to be at the end
|
// NOTE: Nullable
|
||||||
|
//
|
||||||
|
// A expression that does not end with a semicolon, there can only be one of those and it has to be at the end
|
||||||
|
ReturnExpression Expression
|
||||||
}
|
}
|
||||||
|
|
||||||
func (be *BlockExpression) expressionNode() {}
|
func (be *BlockExpression) expressionNode() {}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"runtime/debug"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -149,7 +150,7 @@ func build(outputWriter io.Writer, input string, output string, toPrint ToPrintF
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if panicErr := recover(); panicErr != nil {
|
if panicErr := recover(); panicErr != nil {
|
||||||
err = fmt.Errorf("panic in build: %#v", panicErr)
|
err = fmt.Errorf("panic in build: %#v\n%s", panicErr, debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
4
test.tt
4
test.tt
@ -8,6 +8,6 @@ fn main() = {
|
|||||||
else {
|
else {
|
||||||
hi = 1
|
hi = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
test2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fn test2() = {};
|
||||||
|
@ -118,7 +118,9 @@ func VarResolveExpr(s *Scope, e ast.Expression) error {
|
|||||||
for _, e := range e.Expressions {
|
for _, e := range e.Expressions {
|
||||||
errs = append(errs, VarResolveExpr(&newS, e))
|
errs = append(errs, VarResolveExpr(&newS, e))
|
||||||
}
|
}
|
||||||
errs = append(errs, VarResolveExpr(&newS, e.ReturnExpression))
|
if e.ReturnExpression != nil {
|
||||||
|
errs = append(errs, VarResolveExpr(&newS, e.ReturnExpression))
|
||||||
|
}
|
||||||
|
|
||||||
return errors.Join(errs...)
|
return errors.Join(errs...)
|
||||||
case *ast.IfExpression:
|
case *ast.IfExpression:
|
||||||
@ -145,7 +147,7 @@ func VarResolveExpr(s *Scope, e ast.Expression) error {
|
|||||||
return errorf(e.Token, "variable %q redefined", e.Identifier)
|
return errorf(e.Token, "variable %q redefined", e.Identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.SetUniq(e.Identifier)
|
e.Identifier = s.SetUniq(e.Identifier)
|
||||||
case *ast.VariableReference:
|
case *ast.VariableReference:
|
||||||
v, ok := s.Get(e.Identifier)
|
v, ok := s.Get(e.Identifier)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user