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

Update variable resolution #19

Merged
merged 5 commits into from Jan 14, 2018
Merged

Conversation

ilammy
Copy link
Owner

@ilammy ilammy commented Jan 13, 2018

This is some preparatory refactoring of the variable resolution code so that it is able to support syntactic variables.

This will free up the name which we will need later for kinds of
variables stored in environments (as opposed to kinds of references
resolved by names).
We have forgot another thing that should have mandatory spans: variable
references (see commit e17af9c). All
variables have a definition site. Impored variables have a corresponding
import declaration. All of them can and should have spans.

Make the span non-Optional, remove unwrap()s and expect()s where
necessary, update tests to provide some meaningless spans.
We have been using a linear search for variables. While this works well
for tests for now, later environments may get really big (e.g., the
default imports from (scheme base)). Replace the linear search with hash
table lookup keyed by variable name.

This is also a good place to introduce more variability in variable
kinds. Now we store variables in EnvironmentVariable struct (with their
definition site which may get useful later). The variables are
distinguished by their kind. Currently there is only one variable kind:
runtime variables. Later we will add macro expanders here.
We now store the definition spans of the variables in environments, but
they are not returned back when the variables are resolved. Return them.

For unresolved variables we have to invent some span. The caller should
disregard the returned definition span. I don't like this so it will be
encoded into the type system in the next commit.
This reference kind kinda broken the type safety of the references.
It could be returned by environments as a result of variable resoltion,
but the returned definition span contained bogus value.

Instead of this ugly hack we can use a better idiomatic approach with
Option. Return Option<VariableReference> from environments, use None for
unresolved variables.

Assignment looks kinda ugly with that, but that's because we want to
produce diagnostics nicely ordered. Maybe I will find a better way...
@ilammy
Copy link
Owner Author

ilammy commented Jan 13, 2018

Ugh... well... Travis has failed to launch kcov which fails the build with the following errors:

Can't set personality: Operation not permitted
kcov: error: Can't start/attach to src/libeval/target/debug/eval-9a3422f91fc738fc
Child hasn't stopped: ff00
kcov: error: Can't start/attach to src/libeval/target/debug/eval-9a3422f91fc738fc

This seems to be a known issue, related to the fact that kcov needs to use the personality(2) system call, which seems to be disallowed by Travis. Not sure why Travis allowed it before or why it is disallowed now. Maybe it's some paranoid overreaction to the recent Meltdown/Spectre vulnerabilities.

@ilammy
Copy link
Owner Author

ilammy commented Jan 13, 2018

@ilammy
Copy link
Owner Author

ilammy commented Jan 14, 2018

This seems to be a issue with Travis infrastructure, so I'm going to merge this PR into the staging branch. Hopefully the issue will be resolved by the time we merge the staging branch into master.

@ilammy ilammy merged commit 097b1f3 into new-expander Jan 14, 2018
@ilammy ilammy deleted the update-variable-resolution branch March 9, 2019 19:45
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.

None yet

1 participant