Commit Graph
14 Commits
Author SHA1 Message Date
Richard Smith c8f18446f4 Support explicit conversion of tuples. (#2537)
Allow explicit conversion from a tuple of `T1`, `T2`, ... to a tuple of `U1`, `U2`, ... if each element has an explicit conversion.

Also add a comment to existing `ImplicitAs` impl for tuples explaining its purpose.
2023-01-19 14:56:01 -08:00
Richard SmithandJon Ross-Perkins 0d279b388a Make built-in conversions visible to ImplicitAs. (#2525)
Add a blanket `ImplicitAs` implementation to perform the conversions that explorer can perform as built-in conversions. This allows those conversions to be detected by constraints and to be used as part of other user-defined conversions. For now, a single monolithic conversion is exposed. I intend to split this up into multiple smaller conversion kinds for each kind of conversion in a follow-up change.

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2023-01-18 17:36:55 -08:00
Richard Smith 4daaa4866f Rename Type -> type, per #2360. (#2507)
Also make minor updates to the skeletal design in
docs/design/name_lookup.md following #2113, as there are no longer any prelude names that are made available to unqualified name lookup by default.

Add `type` to the keyword list in
docs/design/lexical_conventions/words.md, following #2360.
2023-01-04 14:22:30 -08:00
Richard Smith 0219218b01 Make type contexts expect a value of type Type. (#2357)
In particular, this means that a type can implement `ImplicitAs(Type)` and have values of that type behave like types.

This implies that `()` and `{}` are no longer types. They are now values whose type is the result of converting `()` or `{}` to type `Type`, as has been discussed recently and seems to be the supported direction. This fixes various cases where these types were previously mishandled.
2022-10-28 08:20:49 -07:00
Jon Ross-Perkins eac7c2bda4 Automate the addition of RUN and simplify RUN lines (#2292)
This was an offshoot of the discussion about how much boilerplate we could remove. lit requires RUN lines be there, everything else is optional.
2022-10-17 13:52:37 -07:00
Jon Ross-Perkins e111418b32 Merge and label stdout/stderr for FileCheck (#2283)
Adds a simple script to merge stdout/stderr and put on labels. This is hidden to the RUN line using lit.cfg.py.

This is my solution to addressing how errors printed by the toolchain break sorting of stdout output; just put stdout first. We could also have toggles for interleaving output or such, which might help test whether we do it properly.

This also moves some previous-distributed replacement logic into lit_autoupdate_base.py: I think having that adjacent to lit.cfg.py is probably the better choice, and it reduces duplication in toolchain scripts. It happens here because I need to change the resulting commands to include the merge.
2022-10-13 14:46:30 -07:00
Jon Ross-Perkins b9d3d9a3df Unify lit.cfg.py approach (#2249)
On #2224 @zygoloid pointed out we needed --implicit-check-not to ensure we were correctly matching output. This is the standard way we're writing explorer tests, so I was looking at unifying our lit approaches.

This is one take on it, making more use of substitutions to bring various testing into alignment, as well as symlinks to avoid config skew (maybe I'll eventually figure out a better solution than symlinks).

Makes a couple small fixes in explorer to remove end-of-line whitespace on output.
2022-10-06 12:25:23 -07:00
Richard Smith 8f0f69b65f Remove RuntimeError / CompilationError. (#2258)
Instead, work out the prefix for an error based on whether it was produced during parsing, semantic analysis, or when running the program.
2022-10-04 15:39:04 -07:00
Thejaswi Kadur 5665f32bf7 Support for user-defined Eq impls (#1730)
Related to #1549; user-defined equality is a prerequisite for user-defined comparison.
2022-07-30 11:51:39 -07:00
Kris JusiakandKris Jusiak b75655852f ✅ [explorer] Add tests for implicit tuple to array conversion (#1582)
Problem:
- Explorer doesn't cover implicit tuple to array conversion.

Solution:
- Add to_array.carbon which converts tuple to array if the size matches.
- Add fail_to_array.carbon which doesn't compile becase the size of array doesn't match the size of tuple.

Co-authored-by: Kris Jusiak <kris@jusiak.net>
2022-07-22 17:26:30 -07:00
Richard Smith 96a663766c Remove support for nesting blocks within blocks. (#1309)
This is not part of the approved design and gets in the way of
supporting `where` expressions, which are part of the approved design.
2022-06-03 18:46:46 -07:00
Richard Smith 0996b203fb Make update_checks.py treat RUNTIME ERROR lines as containing a line number too. (#1246)
Move the corresponding CHECK lines adjacent to their referenced line and use `[[@LINE+n]]`.
2022-05-10 16:05:15 -07:00
Richard SmithandJon Meow e85f45de10 Move CHECK lines in tests next to the line that caused the output. (#1224)
Use FileCheck's `[[@LINE+n]]` mechanism to refer to the next line.

This is made awkward by a couple of things:

* We want to keep the `CHECK` lines in the original order.
* Errors are sometimes more than one line long.

The approach we use is to interleave the original lines and the check lines, putting each check line as early as possible subject to two rules:

1) Check lines never precede the 'AUTOUPDATE' line
2) Except when required by rule (1), a check line that refers to a source line by line number is never placed earlier than a source line that precedes that source line.

The actual `[[@LINE+n]]` annotations are created in a second pass after we've interleaved the lines so that we can work out the correct offsets.

Co-authored-by: Jon Meow <jperkins@google.com>
2022-05-03 15:48:56 -07:00
Jon Meow 309ec35f95 Rename executable_semantics to explorer (#1188)
Change generated with:

```
#!/usr/bin/bash -eux

# Helper script for renaming pending work.
# Run from the repo root.

# Rename executable_semantics in code.
sed -i 's/executable_semantics/explorer/g' \
  $(git grep -l 'executable_semantics' . | grep -v proposals)
sed -i 's/executable semantics/explorer/g' \
  $(git grep -l 'executable semantics' . | grep -v proposals)
sed -i 's/Executable semantics/Explorer/g' \
  $(git grep -l 'Executable semantics' . |  grep -v proposals)
sed -i 's/Executable Semantics/Explorer/g' \
  $(git grep -l 'Executable Semantics' . |  grep -v proposals)
sed -i 's/EXECUTABLE_SEMANTICS/EXPLORER/g' \
  $(git grep -l 'EXECUTABLE_SEMANTICS' . | grep -v proposals)
sed -i 's/ExecutableSemantics/Explorer/g' \
  $(git grep -l 'ExecutableSemantics' . | grep -v proposals)
sed -i 's/executable-semantics/explorer/g' \
  $(git grep -l 'executable-semantics' . | grep -v proposals)

# This is only needed for the initial move.
mv executable_semantics explorer
mv explorer/fuzzing/executable_semantics_fuzzer.cpp explorer/fuzzing/explorer_fuzzer.cpp
```

Verified with `bazel test ...`
2022-04-29 13:20:25 -07:00