@@ -162,6 +162,7 @@ func (g *Generator) Generate(ns *lang.Namespace) error {
162162 formatted , err := format .Source (sourceBytes )
163163 if err != nil {
164164 // If formatting fails, write the unformatted code with the error
165+ g .originalWriter .Write (sourceBytes )
165166 return fmt .Errorf ("formatting failed: %w\n \n Generated code:\n %s" , err , string (sourceBytes ))
166167 }
167168
@@ -272,7 +273,11 @@ func (g *Generator) generateValue(value any) string {
272273 }
273274 return fmt .Sprintf ("lang.NewList(%s)" , strings .Join (vals , ", " ))
274275 }
275- panic (fmt .Sprintf ("unsupported value type %T: %s" , v , v ))
276+
277+ fmt .Println ("Unsupported value type:" , reflect .TypeOf (v ), v )
278+ return "nil"
279+ // TODO: panic
280+ //panic(fmt.Sprintf("unsupported value type %T: %s", v, v))
276281 }
277282}
278283
@@ -675,11 +680,21 @@ func (g *Generator) generateFnMethod(methodNode *ast.FnMethodNode, argsVar strin
675680// generateASTNode generates code for an AST node
676681func (g * Generator ) generateASTNode (node * ast.Node ) string {
677682 switch node .Op {
678- // OpDef
679- // OpSetBang
680- // OpLetFn
681- // OpGo
682- // OpCase
683+ case ast .OpDef :
684+ fmt .Println ("Def not yet implemented; returning nil" )
685+ return "nil"
686+ case ast .OpSetBang :
687+ fmt .Println ("SetBang not yet implemented; returning nil" )
688+ return "nil"
689+ case ast .OpLetFn :
690+ fmt .Println ("LetFn not yet implemented; returning nil" )
691+ return "nil"
692+ case ast .OpGo :
693+ fmt .Println ("Go not yet implemented; returning nil" )
694+ return "nil"
695+ case ast .OpCase :
696+ fmt .Println ("Case not yet implemented; returning nil" )
697+ return "nil"
683698 case ast .OpTry :
684699 return g .generateTry (node )
685700 case ast .OpThrow :
0 commit comments