Commit Graph
20 Commits
Author SHA1 Message Date
f754373786 For loop for arrays (#1753)
Co-authored-by: m new <michael.burzan@outlook.de>
Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-08-09 15:34:24 -07:00
Richard Smith e26bc32343 Change remaining uses of Bool to bool, following #750. (#1901)
The most significant change here is that explorer now uses the chosen spelling
rather than the old `Bool` spelling. Also update a few documentation examples
and some skeletal design docs to use the chosen spelling.
2022-08-03 17:55:34 -07:00
Zenong Zhang 2f4905bf70 Implement static analysis of unformed usage on local variables. (#1831)
- An introprocedural forward analysis that checks the may-be-formed states on local variables.
 - Returns compilation error on usage of must-be-unformed variables. 
 - Implemented as a pass of `ASTNode` traversal. 
 - Currently supports detection of: function parameter, return expression and rhs of assign.
2022-08-03 15:28:51 -07:00
Richard SmithandJon Ross-Perkins ef96f60425 Add support for bitwise operators. (#1809)
Following #1191, add initial support for bitwise operators. Support for both
integer operations and for operator overloading via the interfaces specified in
#1191 is provided.

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2022-07-31 15:25:10 -07:00
Richard Smith 7a67715ac5 Error: track message and prefix/location separately. (#1529)
This allows us to combine multiple Errors together without repeating the prefix
information. Also fixes several cases where two "COMPILATION ERROR" prefixes
would be prepended to the same message when errors with prefixes and locations
were produced by the lexer and parser.
2022-07-26 15:08:19 -07:00
Zenong ZhangandJon Ross-Perkins 52ee050019 Initial implementation of unformed state for local variables. (#1387)
Allows unformed state for local variables. Reports a run-time error when an unformed local variable is used.
- Added declaration without initialization for local variables in the parser.
- Made the init expression of VariableDefinition optional.
- Expanded (alive, dead) to (uninitialized, alive, dead) in the Heap.

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2022-07-20 16:03:52 -04:00
Jon Ross-Perkins 084bc6ebc1 Restructure __intrinsic_print to be a keyword-like Print (#1407) 2022-07-18 13:58:08 -04:00
Jon Ross-Perkins a41915b5af Support basic int printing (#1405)
We don't have overload resolution, so I've simply added PrintInt for now. But it's really tempting to turn __intrinsic_print into a total kludge function.
2022-07-17 23:35:44 -04:00
Jeremy G. Siek b759401328 Heap allocation basics (#1323)
* initial implementation of new and delete

* remove requirement for empty heap from trace.carbon

* more tests

* fixed substitution for generic function types
2022-06-11 18:47:07 -04:00
Jeremy G. Siek 873e78f605 cleanup and docs for tracing output (#1320)
* added documentation for tracing output, changed the printing of scopes to be part of the stack, made other minor changes hoping to enhance readability

* reformat a list in the README

* minor edit

* fix the lists

* updates to the interpreter/README.md
2022-06-09 11:18:21 -04:00
pk19604014 058b5e77c0 Use is_usable logic for recent continuation and choice recursive name lookup fixes (#1312) 2022-06-07 13:10:55 -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
pk19604014 035afdccff Added EnumKindName() for rtti enums + sample usage to print node kind names during type checking (#1305)
Sample trace output:

```
checking tuple pattern (v1: T1, v2: T2), expecting (T1:! ImplicitAs(U1), T2:! ImplicitAs(U2))
checking binding pattern v1: T1, expecting T1:! ImplicitAs(U1)
checking expression pattern T1
checking identifier expression T1
```
2022-06-02 16:16:51 -04:00
pk19604014 f0572ee110 Added fuzzer crash samples as testdata entries (#1299)
For issues #1248, #1249, #1257, #1263
Before the samples were only recorded as fuzzer corpus files which are less 'durable'
2022-05-26 16:18:53 -07:00
pk19604014 f0a34e4bf7 Added TypeCheckTypeExp() and changed function type literal and similar type-checking logic to use the new function (#1256) 2022-05-23 16:26:35 -07:00
Richard Smith 8dd398807d Support user-defined implicit conversions via ImplicitAs (#1273)
Support is added for all of the non-type expression contexts where we currently accept built-in conversions, such as reordering the fields in a struct.
2022-05-20 17:10:30 -07:00
Richard Smith 30642927b0 Fix type of a choice value to be the choice type, not the type-of-choice type. (#1276) 2022-05-18 16:27:58 -07:00
josh11bandJon Meow 0a93289706 Add support for Self and impl as (#1194)
- Makes `Self` a keyword
- Inside `class Foo { `... `}`, `Self` means `Foo`
- Inside `class Foo(T:! Type, U:! Type) {` ...` }`, `Self` means `Foo(T, U)`
- `impl as Bar` means `impl Self as Bar`
- Inside `external impl Foo as Bar {`...`}`, not in a scope already defining `Self`, `Self` means `Foo`

Implemented by introducing a new kind of declaration, a `SelfDeclaration`, that is automatically added to class and impl declarations.

Co-authored-by: Jon Meow <jperkins@google.com>
2022-05-05 18:23:13 -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