fix: add runtime error when new is called on non-class argument
In the interpreter's NEW opcode handler, check if the top-of-stack value is a class before attempting construction. If not, raise a runtime error with a descriptive message instead of silently failing or crashing. Also add a test case (test/new_on_nonclass.wren) that verifies the error is correctly triggered when calling new on a non-class value like an integer.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
var a = 123
|
||||
new a // expect runtime error: Must provide a class to 'new' to construct.
|
||||
Reference in New Issue
Block a user