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

Reducer: Return the locations of runtime errors #763

Closed
OAGr opened this issue Jun 24, 2022 · 3 comments · Fixed by #1172
Closed

Reducer: Return the locations of runtime errors #763

OAGr opened this issue Jun 24, 2022 · 3 comments · Fixed by #1172
Assignees
Labels
Language Regarding Squiggle language semantics, distributions and function registry
Milestone

Comments

@OAGr
Copy link
Contributor

OAGr commented Jun 24, 2022

  • _ Is refactor
  • x Is new feature
  • _ Concerns documentation
@OAGr OAGr added the Language Regarding Squiggle language semantics, distributions and function registry label Jun 24, 2022
@umuro
Copy link
Contributor

umuro commented Jun 28, 2022

@OAGr

Run time errors will not be on the current small piece of code running. Most of the time they will happen inside sth passed by bindings.

Therefore it is impossible to report correct location with bindings based running.

Positions in the parse tree has to be (file, line, column) for correct reporting.

I am suggesting creating a virtual filespace.

  • So that we can parse, compile, run and error report like in all ordinary languages.
  • When a file reference comes in an error, we are sure that we are talking about the same thing.

Virtual file space brings other future advantages because instead of code snipped the whole project is visible to the language.

  • Static type analysis. Like in al file based functional languages. Because we are no more running unbindings.
  • It will still be able to view the variables per file.
  • Complete optimization based on forward usage and detecting unused variables.
  • Making imported source available and yet not evaluating recursively. Because they are simply attached to the virtual filespace.
  • debug and production runtimes. Compiled library objects per file.
  • Pruning unused code and variables.

Then those building commands can be made available easily
parse(fileSpace, filename)
compile(fileSpace, filename)
touch(fileSpace, filename) // resets compilation and variables on filename and all dependents
run(fileSpace, filename) // Also resets variables on all dependents
runFileSpace(fileSpace) // Runs the whole thing.

fileSpace

  • Makes the import mechanism consistent and yet evaluation is the internal business of the language.
  • Errors has fileSpace references without a place for mistake.
  • Stiching a project from different source cells and viewing variables still possible yet running is the internal business of the language.

Cheap workaround without doing is that I add filename parameter to everything and its your business to make sure that we are talking about and displaying the right "filename" on an error or while debugging. Or even the filenames are unique.

But because of optimized runtime, precompilation, filename uniqueness, static type analysis, non-hack imports, etc. I prefer a virtual fileSpace.

A fileSpace will also be the closed boundary project that is compiled, analizedd and run .

For many things to happen we need the files and the dependency graph of the files, to do all things that are possible in all the other languages.

Also having the project which the fileSpace, enables a consistent definition of external tools for the language.
My main motivation for project fileSpace is enabling a static type analysis in the future. 99% of runtime errors will be typing errors.
External bindings are preventing even the simplest type analysis. Moreover running on bindings will become a performance problem. I will keep external data export for viewing only, not for runtime continuation.

On the current Reducer interface errors will not have locations because they are happening somewhere else.

My proposal is that first doing project fileSpace collaboratively. Then we can switch over in 2 steps.

  • Life goes on as it is but we start to evaluate fileSpace references instead of code snippets.
  • Reducer2 with no bindings. We switch to running files and they know their dependencies.
    (We will be able to add dependencies to files. Dependencies and in source fileImports will act the same. Kind of hidden file import for the storybook)

@umuro
Copy link
Contributor

umuro commented Jul 14, 2022

On creating the simplest project data type, evaluate2(<project>, <sourceId>) and spice it with function call error location.
Wrap existing code with error location modifiers corresponding to their parse nodes.

@berekuk
Copy link
Collaborator

berekuk commented Jul 17, 2022

@umuro can you also make evaluate2 async? Even if you don't make runs interruptible yet, it'd be better not to change call signature again when that feature arrives.

@umuro umuro assigned berekuk and unassigned umuro Sep 12, 2022
@berekuk berekuk mentioned this issue Oct 2, 2022
1 task
@berekuk berekuk added this to the 0.5.x milestone Oct 2, 2022
@berekuk berekuk added this to Overview Oct 3, 2022
@berekuk berekuk moved this to 🆕 To prioritize in Overview Oct 3, 2022
@berekuk berekuk moved this from 🆕 To prioritize to 📋 0.5.x in Overview Oct 3, 2022
@berekuk berekuk removed this from Overview Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Regarding Squiggle language semantics, distributions and function registry
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants