Skip to content

fix NotAConstant error help message#8293

Merged
fdncred merged 1 commit intonushell:mainfrom
1Kinoti:fix
Mar 3, 2023
Merged

fix NotAConstant error help message#8293
fdncred merged 1 commit intonushell:mainfrom
1Kinoti:fix

Conversation

@1Kinoti
Copy link
Copy Markdown
Contributor

@1Kinoti 1Kinoti commented Mar 2, 2023

Error: nu::parser::not_a_constant (link)

  × Not a constant.
   ╭─[entry #23:1:1]
 1 │ let file = "/home/user/file"; source $file
   ·                                      ──┬──
   ·                                        ╰── Value is not a parse-time constant
   ╰────
  help: Only a subset of expressions are allowed
        constants during parsing. Try using the 'let'
        command or typing the value literally.

this pr changes the help message to 'Try using the const command ...'

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Mar 3, 2023

nice catch. Thanks.

@fdncred fdncred merged commit e01eb42 into nushell:main Mar 3, 2023
@1Kinoti 1Kinoti deleted the fix branch March 3, 2023 01:13
@kubouch
Copy link
Copy Markdown
Contributor

kubouch commented Mar 3, 2023

The idea behind the error message was that in a situation like const spam = (something that cannot be a constant), it would suggest you to use let instead of const. So the message was correct, just not shown in the right context.

Anyway, help on error messages is always appreciated. When fixing some error message, I recommend searching for the error (NotAConstant in this case) and see in which other situations it is used to avoid breaking them accidentally.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Mar 3, 2023

@kubouch do we need to revert this? Seems like the change is right for this context though.

@kubouch
Copy link
Copy Markdown
Contributor

kubouch commented Mar 3, 2023

I think it's OK but we need to fix the error message in the other context.

@1Kinoti 1Kinoti mentioned this pull request Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants