unisonweb / unison

A friendly programming language from the future

Home Page:https://unison-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

values in watch expressions should not be addable to codebase

kylegoetz opened this issue · comments

I found a way to inadvertently add a watch expression/statement to the codebase

Before describing how to replicate, I want to explain why I think it's the wrong behavior:

In a scratch file, put:

> y = 5

Now run add. No error, but if you clear out the scratch file and view y, you get The following names were not found in the codebase. Check your spelling. back in ucm.

Also, if you ls, y is nowhere to be found.

So far, this makes sense. Watch expressions are not addable to the codebase.

However, if you now put this into a scratch file:

> x = 5
test = do x

add will successfully add test even though it's dependent upon a watch expression.

If you ls or find x you will not find x. If you view test, you will see something like

test : 'Nat
test = do #k09e57l61r

and if you view the hash, you will get

#k09e57l61r : Nat
#k09e57l61r = 5

So the watch expression does get added to the codebase.

I expected add test to fail because it's reliant on something that shouldn't be added to the codebase.

This could be a problem if someone is using watch expressions to test code using credentials that shouldn't be added to the codebase. (I was investigating this behavior specifically because I thought I might be able to test a library using live credentials and put the private stuff in a watch expression to ensure it doesn't get added to the codebase (which is, once added, not removable).