tilt-dev / tilt

Define your dev environment as code. For microservice apps on Kubernetes.
https://tilt.dev/
Apache License 2.0
7.58k stars 298 forks source link

redefining tilt builtins makes things really confusing #2968

Open landism opened 4 years ago

landism commented 4 years ago

e.g.:

sync = config.parse().get('sync', False)
...
docker_build('foo', '.',
  live_update=[
    sync('.', '.')
  })

yields:

Error: invalid call of non-function (string)

which could be really hard to debug! especially if someone makes use of this to, e.g., reassign a function to a wrapper of that function with slightly modified behavior, and then someone else tries to debug it without realizing it's been modified.

It'd be nice if trying to assign to "sync" in the first place generated an error.

nicks commented 4 years ago

In general, programming languages try to avoid the behavior you want here, because it means that adding any new symbol to the global scope would be a breaking change (since any script that defined that symbol would now be an error)

landism commented 4 years ago

Yeah, that's a good reason not to use that solution to this problem. I guess most languages deal with this by not having a global scope, but that feels too heavy-weight for Tilt.

nicks commented 4 years ago

i do think we need to push for / invest in better tooling around starlark, so you can debug things like this, use an ide to jump to the definition, etc