diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..b108416f8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.golden text eol=lf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8664f6d2..1e70bd393 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -78,6 +76,7 @@ jobs: - name: Run race tests env: + GOCACHE: ${{ runner.temp }}/go-build GORACE: "halt_on_error=1" run: go test -race -timeout 120s ./... @@ -85,8 +84,6 @@ jobs: name: Fuzz runs-on: ubuntu-latest timeout-minutes: 20 - env: - GOCACHE: ${{ runner.temp }}/go-build steps: - name: Check out code uses: actions/checkout@v6 @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index f99f167d1..284032365 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ *.out .* +!.gitattributes !.github/ !.github/** diff --git a/compiler/check/synth/phase/extract/function.go b/compiler/check/synth/phase/extract/function.go index ed3f9293c..6c869f641 100644 --- a/compiler/check/synth/phase/extract/function.go +++ b/compiler/check/synth/phase/extract/function.go @@ -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) } diff --git a/fixture_harness_test.go b/fixture_harness_test.go index b12c2060b..36a30f112 100644 --- a/fixture_harness_test.go +++ b/fixture_harness_test.go @@ -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 { diff --git a/types/constraint/infer.go b/types/constraint/infer.go index a43dbf096..7c173cfec 100644 --- a/types/constraint/infer.go +++ b/types/constraint/infer.go @@ -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, @@ -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 { diff --git a/types/typ/subst/subst.go b/types/typ/subst/subst.go index d4b1845ca..d87338750 100644 --- a/types/typ/subst/subst.go +++ b/types/typ/subst/subst.go @@ -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