feat: add compile-time error for 'super' used outside method context

Add isInsideMethod helper that walks the compiler's parent chain to detect
if the current compilation scope is within a method. Use it in super_()
to emit a compile error when 'super' is used at top level or inside a
top-level function, with corresponding test cases for both scenarios.
This commit is contained in:
Bob Nystrom
2013-12-16 06:08:40 +00:00
parent 7638dd2ee2
commit 93cf4e6b87
3 changed files with 32 additions and 18 deletions
+1
View File
@@ -0,0 +1 @@
super.foo // expect error
@@ -0,0 +1,3 @@
fn {
super.foo // expect error
}