Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unbound symbol error when symbol is actually bound #125

Closed
weaversa opened this issue Oct 9, 2014 · 3 comments
Closed

unbound symbol error when symbol is actually bound #125

weaversa opened this issue Oct 9, 2014 · 3 comments
Labels
feature request Asking for new or improved functionality low-hanging fruit For issues that should be easy to fix question Not a task, but rather a question or discussion topic
Milestone

Comments

@weaversa
Copy link
Collaborator

weaversa commented Oct 9, 2014

G = [1, 2, 3, 4]
G' = [ x | x <- [0 .. width(G)-1]]
cryptol> :r
Loading module Cryptol
Loading module Main

[error] unbound symbol: (at test.cry:2:29--2:30, G)
@brianhuffman
Copy link
Contributor

I think this is because width(G)-1 in your example is parsed as a type instead of an expression. G is not in scope as a type variable, so we get the unbound symbol error.

We could definitely improve the error message in this case, perhaps saying "unbound type name" instead of just "unbound symbol". Or we could have a special message just for cases like this where the symbol is in scope as an expression variable but not a type variable.

@weaversa
Copy link
Collaborator Author

I feel that even giving a better error message here would be misleading. That is, I find it confusing that sometimes I can use width and sometimes I can't. I now understand you've placed a restriction on it's use, but I wish it wasn't there.

The main use of width is to get the length of something when a type variable isn't lying around. Even though width takes a value definition as an argument, the length can always be determined at compile time because the value of the definition doesn't matter, only it's type.

What would it take to get the version of width in the type world to provide the length of value definitions?

@kiniry kiniry added question Not a task, but rather a question or discussion topic feature request Asking for new or improved functionality labels Dec 2, 2014
@kiniry kiniry added this to the Someday milestone Dec 2, 2014
elliottt added a commit that referenced this issue Dec 4, 2014
This tries to address #125 by making the errors from the renamer a little bit
more clear.

Squashed commit of the following:

commit 8afd3d7
Author: Trevor Elliott <[email protected]>
Date:   Wed Dec 3 19:33:59 2014 -0800

    Update tests for new renamer errors

commit 7cac018
Author: Trevor Elliott <[email protected]>
Date:   Wed Dec 3 19:33:49 2014 -0800

    Add `at` on errors and warnings to be more consistent

commit 308908b
Author: Trevor Elliott <[email protected]>
Date:   Wed Dec 3 19:06:57 2014 -0800

    More consistent renamer warnings

commit be8100a
Author: Trevor Elliott <[email protected]>
Date:   Wed Dec 3 18:56:53 2014 -0800

    More consistent error formatting from the renamer

commit 26c45c3
Author: Trevor Elliott <[email protected]>
Date:   Wed Dec 3 18:56:36 2014 -0800

    Remove an un-triggerable error

commit ccdb93e
Author: Trevor Elliott <[email protected]>
Date:   Wed Dec 3 16:38:44 2014 -0800

    Try to give better errors for unbound identifiers

commit eb57841
Author: Trevor Elliott <[email protected]>
Date:   Wed Dec 3 16:38:23 2014 -0800

    Remove old TODOs about located errors

commit b984bb5
Author: Trevor Elliott <[email protected]>
Date:   Wed Dec 3 14:37:34 2014 -0800

    Differentiate missing type and expression symbols

commit b9e6f13
Author: Trevor Elliott <[email protected]>
Date:   Wed Dec 3 14:36:52 2014 -0800

    Remove a shadowing warning
@dylanmc dylanmc added the low-hanging fruit For issues that should be easy to fix label Mar 8, 2016
@dylanmc
Copy link
Contributor

dylanmc commented Mar 8, 2016

The error message is much better. Aaron suggests "typeof" to take a value and produce a type, so we could do something like:

width(typeof(G))

in this case. Rob pointed out that we could define a type alias for G, and use that everywhere, but maybe not as satisfying. Yav?

@dylanmc dylanmc assigned elliottt and unassigned yav Mar 8, 2016
@atomb atomb closed this as completed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Asking for new or improved functionality low-hanging fruit For issues that should be easy to fix question Not a task, but rather a question or discussion topic
Projects
None yet
Development

No branches or pull requests

7 participants