Skip to content

Interpolated string is not a parse time constant #11561

@texastoland

Description

@texastoland

Describe the bug

Attempting to import a string using any primitive (use, source, source-env) reports an error like:

Error: �[31mnu::shell::not_a_constant�[0m

  �[31m�[0m Not a constant.
   ╭─[�[36;1;4m/var/folders/tb/pg24gy7x5nbc5c_v1pv1chy00000gn/T/nushell-82712-y5pRVbCy7aXR�[0m:1:1]
 �[2m1�[0m │ use $'any/script.nu'
   · �[35;1m    ────────┬───────�[0m
   ·             �[35;1m╰── �[35;1mValue is not a parse-time constant�[0m�[0m
   ╰────
�[36m  help: �[0mOnly a subset of expressions are allowed constants during parsing.
        Try using the 'const' command or typing the value literally.

Separate issue: this particular error doesn't strip terminal colors in the LSP for some reason.

How to reproduce

use $'any/script.nu'

Expected behavior

I expected it to work like `'any' + /script.nu.

Screenshots

No response

Configuration

key value
version 0.89.0
branch
commit_hash
build_os macos-x86_64
build_target x86_64-apple-darwin
rust_version rustc 1.75.0 (82e1608df 2023-12-21) (Homebrew)
cargo_version cargo 1.75.0
build_time 2024-01-09 20:16:29 +00:00
build_rust_channel release
allocator mimalloc
features dataframe, default, extra, sqlite, trash, which, zip
installed_plugins

Additional context

I discovered it trying to work around #7849 (another low-hanging fruit) another way 🍒

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions