Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.golden text eol=lf
25 changes: 14 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 15
env:
GOCACHE: ${{ runner.temp }}/go-build
GOLANGCI_LINT_CACHE: ${{ runner.temp }}/golangci-lint
steps:
- name: Check out code
uses: actions/checkout@v6
Expand All @@ -32,6 +29,9 @@ jobs:

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9.2.0
env:
GOCACHE: ${{ runner.temp }}/go-build
GOLANGCI_LINT_CACHE: ${{ runner.temp }}/golangci-lint
with:
version: v2.8.0
only-new-issues: false
Expand All @@ -45,8 +45,6 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
env:
GOCACHE: ${{ runner.temp }}/go-build
steps:
- name: Check out code
uses: actions/checkout@v6
Expand All @@ -58,14 +56,14 @@ jobs:
cache: true

- name: Run tests
env:
GOCACHE: ${{ runner.temp }}/go-build
run: go test -timeout 120s ./...

race:
name: Race Tests
runs-on: ubuntu-latest
timeout-minutes: 40
env:
GOCACHE: ${{ runner.temp }}/go-build
steps:
- name: Check out code
uses: actions/checkout@v6
Expand All @@ -78,15 +76,14 @@ jobs:

- name: Run race tests
env:
GOCACHE: ${{ runner.temp }}/go-build
GORACE: "halt_on_error=1"
run: go test -race -timeout 120s ./...

fuzz:
name: Fuzz
runs-on: ubuntu-latest
timeout-minutes: 20
env:
GOCACHE: ${{ runner.temp }}/go-build
steps:
- name: Check out code
uses: actions/checkout@v6
Expand All @@ -98,20 +95,24 @@ jobs:
cache: true

- name: Fuzz type decode
env:
GOCACHE: ${{ runner.temp }}/go-build
run: go test -fuzz=FuzzTypeDecodeToValidation -fuzztime=60s -timeout=120s

- name: Fuzz Lua source types
env:
GOCACHE: ${{ runner.temp }}/go-build
run: go test -fuzz=FuzzLuaTypeValidation -fuzztime=60s -timeout=120s

- name: Fuzz Lua with manifest
env:
GOCACHE: ${{ runner.temp }}/go-build
run: go test -fuzz=FuzzLuaWithManifestTypes -fuzztime=60s -timeout=120s

bench:
name: Benchmarks
runs-on: ubuntu-latest
timeout-minutes: 15
env:
GOCACHE: ${{ runner.temp }}/go-build
steps:
- name: Check out code
uses: actions/checkout@v6
Expand All @@ -123,6 +124,8 @@ jobs:
cache: true

- name: Run benchmarks
env:
GOCACHE: ${{ runner.temp }}/go-build
run: go test -bench="Benchmark(Validate|Is)" -benchmem -count=1 -timeout=60s | tee bench.txt

- name: Upload benchmark results
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*.out

.*
!.gitattributes
!.github/
!.github/**

Expand Down
2 changes: 1 addition & 1 deletion compiler/check/synth/phase/extract/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (s *Synthesizer) synthFunctionTypeWithCapturePoint(

// Build CFG once, shared between overlay inference and return inference.
var fnGraph *cfg.Graph
if fn.Stmts != nil && len(fn.Stmts) > 0 {
if len(fn.Stmts) > 0 {
fnGraph = s.getOrBuildFunctionGraph(fn)
}

Expand Down
2 changes: 1 addition & 1 deletion fixture_harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func matchesExpectation(exp inlineExpectation, d diag.Diagnostic, entryFile stri
expFile := exp.File
// Match diagnostic file: d.Position.File is set by the checker (e.g. "test.lua" or module name)
if !strings.HasSuffix(d.Position.File, strings.TrimSuffix(expFile, ".lua")) &&
!(expFile == entryFile && d.Position.File == "test.lua") {
(expFile != entryFile || d.Position.File != "test.lua") {
return false
}
if d.Position.Line != exp.Line {
Expand Down
81 changes: 0 additions & 81 deletions types/constraint/infer.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ func (c *InferSet) unifySCC(scc []int) {
}
}

// walkType traverses a type tree, calling pred on each node.
// Returns true if pred returns true for any node.
func canContainTypeVar(k kind.Kind) bool {
switch k {
case kind.Optional, kind.Union, kind.Intersection, kind.Array,
Expand All @@ -386,85 +384,6 @@ func canContainTypeVar(k kind.Kind) bool {
}
}

func walkType(t typ.Type, depth int, pred func(typ.Type) bool) bool {
if stopDepth(t, depth) {
return false
}

if pred(t) {
return true
}

if !canContainTypeVar(t.Kind()) {
return false
}

return typ.Visit(t, typ.Visitor[bool]{
Optional: func(o *typ.Optional) bool {
return walkType(o.Inner, depth+1, pred)
},
Union: func(u *typ.Union) bool {
for _, m := range u.Members {
if walkType(m, depth+1, pred) {
return true
}
}
return false
},
Intersection: func(in *typ.Intersection) bool {
for _, m := range in.Members {
if walkType(m, depth+1, pred) {
return true
}
}
return false
},
Tuple: func(tup *typ.Tuple) bool {
for _, e := range tup.Elements {
if walkType(e, depth+1, pred) {
return true
}
}
return false
},
Array: func(a *typ.Array) bool {
return walkType(a.Element, depth+1, pred)
},
Map: func(m *typ.Map) bool {
return walkType(m.Key, depth+1, pred) || walkType(m.Value, depth+1, pred)
},
Function: func(fn *typ.Function) bool {
for _, p := range fn.Params {
if walkType(p.Type, depth+1, pred) {
return true
}
}

for _, r := range fn.Returns {
if walkType(r, depth+1, pred) {
return true
}
}

return walkType(fn.Variadic, depth+1, pred)
},
Record: func(r *typ.Record) bool {
for _, f := range r.Fields {
if walkType(f.Type, depth+1, pred) {
return true
}
}
return false
},
Alias: func(a *typ.Alias) bool {
return walkType(a.Target, depth+1, pred)
},
Default: func(t typ.Type) bool {
return false
},
})
}

func occursIn(varID int, t typ.Type) bool {
seen := make(map[typ.Type]bool)
return walkTypeMemo(t, 0, seen, func(inner typ.Type) bool {
Expand Down
10 changes: 0 additions & 10 deletions types/typ/subst/subst.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,6 @@ func putExpandMemo(m map[typ.Type]typ.Type) {
expandMemoPool.Put(m)
}

func expandInstantiatedWithDepth(t typ.Type, maxDepth int) typ.Type {
if t == nil || !expandInstantiatedCanDescend(t) {
return t
}
memo := getExpandMemo()
defer putExpandMemo(memo)
guard := typ.GuardForDepth(maxDepth)
return expandInstantiatedGuard(t, guard, memo)
}

func expandInstantiatedGuard(t typ.Type, guard internal.RecursionGuard, memo map[typ.Type]typ.Type) typ.Type {
if t == nil || !expandInstantiatedCanDescend(t) {
return t
Expand Down
Loading