Skip to content

Commit 176a3cc

Browse files
authored
fixes: 'method' is only allowed at top level (#1173)
1 parent 91f28e7 commit 176a3cc

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/nimony/semdecls.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ proc attachConverter(c: var SemContext; symId: SymId;
423423

424424
proc attachMethod(c: var SemContext; symId: SymId;
425425
declStart, beforeParams, beforeGenericParams: int; info: PackedLineInfo) =
426+
if c.currentScope.up.kind != ToplevelScope:
427+
buildErr c, info, "'method' is only allowed at top level"
428+
426429
var params = cursorAt(c.dest, beforeParams)
427430
var root = SymId(0)
428431
var signature = StrId(0)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/nimony/methods/tlocalmethods.nim(7, 3) Error: 'method' is only allowed at top level
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
type
3+
TestTestObj = ref object of RootObj
4+
id: int
5+
6+
block:
7+
method foo(x: TestTestObj) =
8+
discard

0 commit comments

Comments
 (0)