mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
parent
f33e8fdbac
commit
dae4065f3f
3 changed files with 12 additions and 9 deletions
|
|
@ -239,12 +239,15 @@ pub const Repl = struct {
|
|||
return try std.fmt.allocPrint(self.allocator, "assigned `{s}`", .{info.var_name});
|
||||
},
|
||||
.type_annotation => |info| {
|
||||
// Store the type annotation for future use
|
||||
// For type annotations:
|
||||
// 1. Store them as definitions for future use
|
||||
try self.addOrReplaceDefinition(info.source, info.var_name);
|
||||
|
||||
// Type annotations alone cannot be evaluated - they create e_anno_only which crashes when used
|
||||
// Return a message indicating the annotation was stored
|
||||
return try std.fmt.allocPrint(self.allocator, "Crash: runtime error", .{});
|
||||
// 2. Evaluate the full source (including all definitions + this annotation)
|
||||
// This will create an e_anno_only which will crash when evaluated
|
||||
const full_source = try self.buildFullSource(input);
|
||||
defer self.allocator.free(full_source);
|
||||
return try self.evaluateSource(full_source);
|
||||
},
|
||||
.import => {
|
||||
// Imports are not supported in this implementation
|
||||
|
|
|
|||
|
|
@ -402,10 +402,10 @@ test "Repl - standalone annotation should crash, then call should fail - REGRESS
|
|||
const result2 = try repl.step("foo(\"test\")");
|
||||
defer std.testing.allocator.free(result2);
|
||||
|
||||
// Should return a canonicalization error since foo only has a type annotation, no definition
|
||||
if (std.mem.indexOf(u8, result2, "Canonicalize expr error") == null) {
|
||||
std.debug.print("\nexpected Canonicalize expr error, got: {s}\n", .{result2});
|
||||
// Should return "Evaluation error: error.TypeMismatch"
|
||||
if (std.mem.indexOf(u8, result2, "TypeMismatch") == null) {
|
||||
std.debug.print("\nexpected TypeMismatch, got: {s}\n", .{result2});
|
||||
return error.TestUnexpectedResult;
|
||||
}
|
||||
try testing.expect(std.mem.indexOf(u8, result2, "expression returned null for apply") != null);
|
||||
try testing.expect(std.mem.indexOf(u8, result2, "Evaluation error") != null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ type=repl
|
|||
# OUTPUT
|
||||
Crash: runtime error
|
||||
---
|
||||
Canonicalize expr error: expression returned null for apply
|
||||
Evaluation error: error.TypeMismatch
|
||||
# PROBLEMS
|
||||
NIL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue