• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

forst-lang / forst / 16089939345

05 Jul 2025 04:20PM UTC coverage: 39.652% (+2.3%) from 37.308%
16089939345

push

github

web-flow
feat: Shape guards (#17)

2211 of 6179 new or added lines in 87 files covered. (35.78%)

102 existing lines in 32 files now uncovered.

3719 of 9379 relevant lines covered (39.65%)

6.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

59.26
/forst/internal/parser/scope_stack.go
1
package parser
2

3
import (
4
        "github.com/sirupsen/logrus"
5
)
6

7
// ScopeStack manages a stack of scopes during type checking
8
type ScopeStack struct {
9
        scopes  []*Scope
10
        current *Scope
11
        log     *logrus.Logger
12
}
13

14
// NewScopeStack creates a new stack with a global scope
15
func NewScopeStack(log *logrus.Logger) *ScopeStack {
65✔
16
        globalScope := NewScope("", true, false, log)
65✔
17
        scopes := []*Scope{globalScope}
65✔
18
        return &ScopeStack{
65✔
19
                scopes:  scopes,
65✔
20
                current: globalScope,
65✔
21
                log:     log,
65✔
22
        }
65✔
23
}
65✔
24

25
// PushScope creates and pushes a new scope for the given AST node
26
func (ss *ScopeStack) PushScope(scope *Scope) {
32✔
27
        if scope.IsGlobal {
32✔
NEW
28
                ss.log.Fatalf("Cannot push global scope")
×
NEW
29
        }
×
30
        ss.scopes = append(ss.scopes, scope)
32✔
31
        ss.current = scope
32✔
32
}
33

NEW
34
func (ss *ScopeStack) PopScope() {
×
NEW
35
        if ss.current.IsGlobal {
×
NEW
36
                ss.log.Fatalf("Cannot pop global scope")
×
NEW
37
        }
×
NEW
38
        ss.scopes = ss.scopes[:len(ss.scopes)-1]
×
NEW
39
        ss.current = ss.scopes[len(ss.scopes)-1]
×
40
}
41

42
func (ss *ScopeStack) CurrentScope() *Scope {
32✔
43
        return ss.current
32✔
44
}
32✔
45

NEW
46
func (ss *ScopeStack) GlobalScope() *Scope {
×
NEW
47
        return ss.scopes[0]
×
NEW
48
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc