diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml deleted file mode 100644 index f6152c87..00000000 --- a/.github/workflows/golangci-lint.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: golangci-lint -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - # Optional: allow read access to pull request. Use with `only-new-issues` option. - # pull-requests: read - -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - - uses: actions/setup-go@v5 - with: - go-version: '1.21' - cache: false - - - name: golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - # Require: The version of golangci-lint to use. - # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. - # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. - version: v1.54 - - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - # - # Note: By default, the `.golangci.yml` file should be at the root of the repository. - # The location of the configuration file can be changed by using `--config=` - # args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0 - - # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true - - # Optional: if set to true, then all caching functionality will be completely disabled, - # takes precedence over all other caching options. - # skip-cache: true - - # Optional: if set to true, then the action won't cache or restore ~/go/pkg. - # skip-pkg-cache: true - - # Optional: if set to true, then the action won't cache or restore ~/.cache/go-build. - # skip-build-cache: true - - # Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'. - # install-mode: "goinstall" diff --git a/.golangci.yml b/.golangci.yml index 3d2a918a..62fe9b3f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -86,9 +86,9 @@ linters: - dogsled # - dupl - errcheck - - exportloopref + # - exportloopref -- no more on 1.23.1 # - funlen - - gocheckcompilerdirectives + #- gocheckcompilerdirectives --x - gochecknoinits # - goconst # - gocritic @@ -105,12 +105,12 @@ linters: # - lll - misspell # - nakedret - - noctx - - nolintlint + # - noctx --- x + # - nolintlint --- x # - revive - staticcheck # - stylecheck - - typecheck + # - typecheck # --- temporarily removed, was throwing weird errors after upgrade to 1.23.1 on 20240925 - unconvert # l1 - unparam # - unused @@ -134,8 +134,8 @@ linters: issues: # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: - - text: "evaldo" - linters: typecheck +# - text: "evaldo" +# linters: typecheck - text: "net/http/cgi" # REASON: only important for Go 1.6 and lower, Rye requires go1.8 or higher as defined in go.mod linters: gosec diff --git a/env/env.go b/env/env.go index ae3deea3..d6906f5f 100755 --- a/env/env.go +++ b/env/env.go @@ -2,6 +2,7 @@ package env import ( "fmt" + "reflect" "sort" "strings" "sync" @@ -14,6 +15,12 @@ import ( Set(word int, val Object) Object } */ +// UTIL + +func IsPointer(v interface{}) bool { + return reflect.TypeOf(v).Kind() == reflect.Ptr +} + // This is experimental env without map for Functions with up to two variables type EnvR2 struct { diff --git a/evaldo/builtins.go b/evaldo/builtins.go index f252717d..fdac2e5a 100644 --- a/evaldo/builtins.go +++ b/evaldo/builtins.go @@ -813,6 +813,34 @@ var builtins = map[string]*env.Builtin{ return &sp case *env.Spreadsheet: return sp + case env.Dict: + return &sp + case env.List: + return &sp + case env.Block: + return &sp + default: + return MakeArgError(ps, 1, []env.Type{env.SpreadsheetType}, "thaw") + } + }, + }, + + "freeze": { + Argsn: 1, + Doc: "Makes a value (currently only spreadsheets) again immutable", + Pure: true, + Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object { + switch sp := arg0.(type) { + case env.Spreadsheet: + return sp + case *env.Spreadsheet: + return *sp + case *env.Dict: + return *sp + case *env.List: + return *sp + case *env.Block: + return *sp default: return MakeArgError(ps, 1, []env.Type{env.SpreadsheetType}, "thaw") } @@ -1684,21 +1712,41 @@ var builtins = map[string]*env.Builtin{ if !esc { return obj } + case *env.Block: + obj, esc := term.DisplayBlock(*bloc, ps.Idx) + if !esc { + return obj + } case env.Dict: obj, esc := term.DisplayDict(bloc, ps.Idx) if !esc { return obj } + case *env.Dict: + obj, esc := term.DisplayDict(*bloc, ps.Idx) + if !esc { + return obj + } case env.Spreadsheet: obj, esc := term.DisplayTable(bloc, ps.Idx) if !esc { return obj } + case *env.Spreadsheet: + obj, esc := term.DisplayTable(*bloc, ps.Idx) + if !esc { + return obj + } case env.SpreadsheetRow: obj, esc := term.DisplaySpreadsheetRow(bloc, ps.Idx) if !esc { return obj } + case *env.SpreadsheetRow: + obj, esc := term.DisplaySpreadsheetRow(*bloc, ps.Idx) + if !esc { + return obj + } } return arg0 diff --git a/go.mod b/go.mod index c31ae58c..4ac41540 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module github.com/refaktor/rye go 1.21 -// toolchain go1.21.5 - retract v0.0.11 // Published accidentally with a bug require ( @@ -32,7 +30,6 @@ require ( github.com/mrz1836/postmark v1.6.5 github.com/pkg/term v1.2.0-beta.2.0.20211217091447-1a4a3b719465 github.com/refaktor/go-peg v0.0.0-20220116201714-31e3dfa8dc7d - github.com/refaktor/liner v1.2.10 github.com/sashabaranov/go-openai v1.29.0 github.com/shirou/gopsutil/v3 v3.24.5 github.com/thomasberger/parsemail v1.2.7 diff --git a/go.sum b/go.sum index 189bc392..aef74b4e 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,6 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.30.7 h1:NKTa1eqZYw8tiHSRGpP0VtTdub/8 github.com/aws/aws-sdk-go-v2/service/sts v1.30.7/go.mod h1:NXi1dIAGteSaRLqYgarlhP/Ij0cFT+qmCwiJqWh/U5o= github.com/aws/smithy-go v1.20.4 h1:2HK1zBdPgRbjFOHlfeQZfpC4r72MOb9bZkiFwggKO+4= github.com/aws/smithy-go v1.20.4/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= -github.com/bitfield/script v0.22.1 h1:DphxoC5ssYciwd0ZS+N0Xae46geAD/0mVWh6a2NUxM4= -github.com/bitfield/script v0.22.1/go.mod h1:fv+6x4OzVsRs6qAlc7wiGq8fq1b5orhtQdtW0dwjUHI= github.com/bitfield/script v0.23.0 h1:N0R5yLEl6wJIS9PR/A6xXwjMsplMubyxdi05N5l0X28= github.com/bitfield/script v0.23.0/go.mod h1:fv+6x4OzVsRs6qAlc7wiGq8fq1b5orhtQdtW0dwjUHI= github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA= @@ -152,7 +150,6 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= @@ -176,8 +173,6 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/refaktor/go-peg v0.0.0-20220116201714-31e3dfa8dc7d h1:FXrWUGgPRzhaZIBho8zNLSrMp0VpP8E9+wbRRnJYlbE= github.com/refaktor/go-peg v0.0.0-20220116201714-31e3dfa8dc7d/go.mod h1:iIkrsFobLIWX8kQ6Oqj4cl4nwdMSE92DWpWwk9YlG9s= -github.com/refaktor/liner v1.2.10 h1:MjbQj9EfNuSFnNk9zan37xpkNIRpsWKenyIBg7FZdVw= -github.com/refaktor/liner v1.2.10/go.mod h1:ziZSGVYZ4OzZ9kbeB254MtIrxxQlDibULRQGlDi1iK8= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -227,7 +222,6 @@ golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/runner/runner.go b/runner/runner.go index fffd7ebe..bf488df6 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -441,7 +441,7 @@ func main_rye_repl(_ io.Reader, _ io.Writer, subc bool, here bool, lang string, // userHomeDir, _ := os.UserHomeDir() // profile_path := filepath.Join(userHomeDir, ".rye-profile") - fmt.Println("Welcome to Rye console. Use ls to list current or lsp and lsp\\ \"prin\" to list parent contexts.") + fmt.Println("Welcome to Rye console. Use lc to list current or lcp and lcp\\ \"pri\" to list parent contexts.") //if _, err := os.Stat(profile_path); err == nil { //content, err := os.ReadFile(profile_path)