fix: guard against segfault when super is called at top level with no args

When `super` is invoked at the top level without an explicit method name, the compiler previously dereferenced a NULL `enclosingClass` pointer while trying to copy the enclosing method's signature. This change adds a NULL check for `enclosingClass` in the `super_` function, setting an empty method name and zero length when the pointer is NULL, preventing the segmentation fault. Also extends the test file `super_at_top_level.wren` with additional cases for bare `super`, `super.foo("bar")`, and `super("foo")` to verify error handling for these top-level super invocations.
This commit is contained in:
Bob Nystrom
2015-01-12 03:42:26 +00:00
2 changed files with 13 additions and 2 deletions
+3
View File
@@ -1 +1,4 @@
super.foo // expect error
super // expect error
super.foo("bar") // expect error
super("foo") // expect error