Commit Graph
1653 Commits
Author SHA1 Message Date
Jon Ross-Perkins b9bd7e1eff Turn addr self in destructors into an error. (#2803)
Previously crashed. See #2802
2023-05-01 11:30:19 -07:00
Jon Ross-Perkins 0732d5857d Collapse StringifyNodeImpl (#2806)
I realized I should've done this in #2804 since the removal of recursion makes the separate function no longer necessary.
2023-04-27 10:16:28 -07:00
Richard Smith b235b53e95 Break long ground rule bullet into multiple bullets (#2805)
This makes the bullets more self-consistent and easier to read, and makes this list match the list in the code of conduct.
2023-04-26 16:42:46 -07:00
Jon Ross-Perkins 32ea47f068 Make stringification non-recursive. (#2804) 2023-04-26 15:56:30 -07:00
Jon Ross-Perkins ad52f1e547 Fix lit_autoupdate for explorer (#2801)
#2793 added a README.md, #2796 added the non-auto-updated test.
2023-04-26 13:52:16 -07:00
debe4cc151 Defining the 0.1 language (#2759)
Provide a clear definition of our goals for the 0.1 Carbon language, and a
concrete feature-set that is expected to satisfy these goals.

The high level goal proposed for the 0.1 language is to reach an evaluation-MVP
(Minimal Viable Product): it should be sufficiently complete to evaluate its
suitability specifically with respect to fitness as a C++ successor language.

The features proposed for 0.1 language in turn focus on C++ interoperability and
a minimal subset of foundational aspects of the language.

Beyond the language itself, the other project features and milestones proposed
focus on enabling evaluation of the language design and interoperating with C++
in practice.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: jonmeow <jperkins@google.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2023-04-25 18:19:06 -07:00
Jon Ross-Perkins 6ade982c6f Fix missing fuzzing proto dep (#2800)
protobuf deps have become complexly structured, but AFAICT this is still the preferred dep. Also fixes some the fuzzer include checking, but that's a trivial misconfig.
2023-04-25 14:32:21 -07:00
Jon Ross-Perkins 8715cded29 Prevent generic bindings in binding types (#2789)
Adds TODO #2788 for the bigger refactoring.

Fixes #2783
2023-04-24 14:06:35 -07:00
Manmeet Singh 90577f18a0 fix alias resolved_declaration error (#2796)
Closes #2794
2023-04-24 10:02:04 -07:00
Lucile Rose Nihlen c180e6367b [explorer] fix assert when aliasing interface as member (#2792)
Note that this code still results in a compilation error pending the merge of #2628, this just prevents the assertion from happening.

Closes #2583.
2023-04-24 08:05:31 -07:00
Jon Ross-Perkins b828093c87 Start checking for a few possible resource exhaustion scenarios for explorer (#2793)
I couldn't figure out a way to actually hit a reasonable out-of-memory case once I add the maximum interpreter step count. However, the step count limit seems more important.

I've moved the todo stack limit out of function calls because there are plenty of ways to build up the todo stack without any function calls.

Fixes #2791
2023-04-21 15:14:14 -07:00
Manmeet Singh f310316ef4 fix printing for single element tuple values (#2786)
adds trailing comma to single element tuple

example:
```carbon
package ExplorerTest api;

fn Main() -> i32
{
  var a: (i32,) = (1, 2);
  return 0;
}

```

change in error message:
```diff
-type error in initializer of variable: '(i32, i32)' is not implicitly convertible to '(i32)'
+type error in initializer of variable: '(i32, i32)' is not implicitly convertible to '(i32,)'
```
2023-04-21 09:34:22 -07:00
Manmeet Singh 7eabd0a64a fix incorrect condition in InSameMatchFirst (#2773)
fixes a typo
2023-04-21 09:28:37 -07:00
Jon Ross-Perkins d12583fc08 Do cleanup on explorer fuzzing infrastructure. (#2790)
I'm partly doing this because the current setup would be difficult to share with the toolchain. e.g., ProtoToCarbon isn't explorer-specific, but the only way to run it via CLI is the explorer's fuzzverter. I want a separate tool.

This change:

- Adds a //common/fuzzing:proto_to_carbon tool.
  - The rest of fuzzverter is now just //explorer/fuzzing:ast_to_proto.
  - The change simplifies overall handling and removes a LLVM CLI dependency.
- Stops allowing unknown fields in the proto.
  - This has mostly led to forgetting to remove fuzzer inputs that were for removed features.
- Moves more non-explorer-specific bits to //common/fuzzing.
- Cleans up remaining pieces in //explorer/fuzzing
  - Merges the //explorer/fuzzing proto tests, which deduplicates AstToString copies.
    - These tests also had duplicate dependencies, etc -- and all complete in ~6s.
  - Updates and fixes regen_corpus which was previously broken by other changes.
  - Updates the README to reflect changes.
- Removes obsolete proto-fuzzer build configuration (AFAICT this is no longer needed).
2023-04-21 08:23:58 -07:00
Jon Ross-Perkins c9f0ef9e2c Require names where we expect binding patterns (#2782)
This also clusters the various `var` tests. This tests similar patterns for a few syntaxes, but `fn f(x: i32, i32) {}` and local variables `var (x: i32, i32);` and `var i32;` were the crashers I found.

In `fn`, the `x: i32,` is helpful to convince the parser that this is valid syntax.

Fixes #2778
2023-04-20 10:58:03 -07:00
masbuz ac10b36595 Fix BindingPattern type check handling (#2777) (#2787)
Recursive call of TypeCheckPattern ignored 'expected' parameter.

Closes #2777
2023-04-20 09:48:36 -07:00
Jon Ross-Perkins de9d6e7546 Trim the parse tree fuzzer corpus using -merge=1 (#2785) 2023-04-19 17:56:39 -07:00
Jon Ross-Perkins 62ee4a5c7a Suppress Print intrinsic output in the fuzzer. (#2784)
Related to #2780, but mostly an issue when running over the committed corpus since we use Print a lot.
2023-04-19 16:56:02 -07:00
Jon Ross-Perkins 39155d34ae Remove experimental continuation support (#2776)
Removes `__continuation`, `__await`, and `__run`.

In part here, the discussion was that while the feature had been useful for validating the early explorer design, it's no longer needed for that role as the explorer is now quite robust. Continuations have been experimental and, at this point, don't have an owner pushing to a proposal.

The triggering factor is that, as we push to address fuzzer issues, I ran into a crash bug in this code; basically, `fn Main() -> i32 { __await; return 0; }`. When I mentioned this, the reaction seemed to trend towards removal of the feature.
2023-04-19 14:22:43 -07:00
Jon Ross-Perkins 60059ff726 Type check the mix argument before interpreting it (#2781)
This is a crash bug.

Fixes #2779
2023-04-19 11:56:39 -07:00
Jon Ross-Perkins b07f9295d7 Stop printing per-input results in fuzzer (#2780)
Right now, running the fuzzer in fuzzing mode is pretty noisy due to this output; it makes it hard to see the fuzzer's own progress output. It's also not really needed: users can run explorer on inputs more directly, without using this tool (albeit with fuzzverter), if they want to see detailed results.
2023-04-19 11:55:47 -07:00
Manmeet Singh 68e15c37a3 feat: implement namespace alias (#2720)
Fixes 

https://github.com/carbon-language/carbon-lang/blob/46503c0a9d20d8e38dde1ff4266f4e2b98699669/explorer/interpreter/resolve_names.cpp#L281

This was super fun to implement as first contribution. Learnt a lot about how the interpreter works while digging through the code and trying different ways to fix it.
2023-04-17 15:56:31 -07:00
Jon Ross-Perkins 710eb0480c Add validation of Print format strings (#2765)
Also adds some validation of various direct print intrinsic calls.

Fixes #2734
2023-04-17 11:45:21 -07:00
Manmeet Singh 951cac9607 clang-tidy cleanup (#2774)
running clang-tidy locally got a bunch of warning. 

I have ignored `bugprone-unchecked-optional-access` for now, because there are large number of occurrences.
2023-04-17 10:15:11 -07:00
Jon Ross-Perkins 3cab211489 Change handling of invalid patterns to produce a valid parse tree. (#2768)
At present, `var *;` is a crash because it has errors that weren't being properly stored/handled. This changes the handling to give more to track invalid parses in patterns.
2023-04-15 03:22:31 -07:00
Jon Ross-Perkins 1f49c3e36d Add some validation of as intrinsics. (#2767) 2023-04-13 12:53:49 -07:00
Jon Ross-Perkins d7978deb3a Start doing more validation of intrinsics: assert, new, delete, rand (#2766)
This is adding more validation of intrinsics. It addresses a bug in rand where CHECK-fails would occur for bad range inputs, instead of a runtime error. I'm also addressing what I think was an int32 range issue in the handling by running the generator with int64.
2023-04-13 12:53:34 -07:00
Jon Ross-Perkinsandmingodad d52836e854 Switch bison variables to $[...] (#2756)
This is using the idea from #2264, but written from scratch.

Co-authored-by: mingodad
2023-04-13 12:48:27 -07:00
Amr Hesham 0fd0855da0 Detect duplicate struct member names (#2764)
Detect struct literal or struct type literal member duplicate name

Closes #2762
2023-04-12 16:24:29 -07:00
Jon Ross-Perkins 694dd7bf55 Fix poor dyn_cast usage (#2763)
Note the dest_class case didn't actually check dyn_cast success until after using the pointer. That's the case I noticed first, but also cleaning up a couple other small related things.
2023-04-12 15:56:27 -07:00
Jon Ross-Perkins 9245e17d4c Validate that the argument to __mix is a mixin. (#2757) 2023-04-12 09:25:43 -07:00
Jon Ross-Perkins 819c1745c7 Fix handling of struct conversions in deduction (#2758)
This case previously crashed. Trying to handle allow_implicit_conversion better per discussion; I've split out the for loop for each path because I think it's now clearer this way.
2023-04-11 15:50:03 -07:00
Jon Ross-Perkins 81a7adc0e5 Fix handling of invalid struct entries (#2755)
This was incorrectly setting the finish state back to unknown, which resulted in a check. Instead, the finish state should be maintained.
2023-04-10 15:54:43 -07:00
Manmeet Singh 7979c886e0 fix: incorrect loop in builtins_indexes (#2751)
Replaces the incorrect `<=` with `<`. Earlier this also included `Builtin::Invalid` which is meant to be used as count of Builtins.

Closes #2729
2023-04-10 13:37:57 -07:00
Manmeet Singh d9e37da4fb fix: set StaticScope::NameStatus correctly for Associated Constants (#2752)
The StaticScope::NameStatus pattern is not being correctly follow for associated constant deceleration.

Closes #2728
Closes #2730
2023-04-10 13:21:32 -07:00
Manmeet Singh 72d8f86e79 fix: incorrect index in TypeEqual for ConstraintType (#2754)
Just a typo.

Closes #2727
2023-04-10 13:17:33 -07:00
31e907178f Termination algorithm for impl selection (#2687)
This proposal replaces the termination algorithm for `impl` selection. The previous algorithm relied on a recursion limit, which is counter to [our goal for predictability](/docs/design/generics/goals.md#predictability).

The replacement is to terminate if any `impl` declaration depends transitively on itself with a "strict superset" type as one of its parameters.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Satakshi Garg <56358125+satakshigarg@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-04-10 13:15:07 -07:00
Amr Hesham 08f8c9bb27 Explorer: Move Concrete type check for Variable Definition to the type checker (#2750)
Move concrete type check for Variable Definition (Local variable) from interpreter to type checker using the `ExpectConcreteType` function created in #2748
2023-04-10 12:15:49 -07:00
Amr Hesham 0dc80bac01 Explorer: Report compiletime error when global variable type is abstract (#2748)
Add concrete type check for Variable Declaration to report a compile time error when the variable type is abstract

Closes #2747
2023-04-07 17:37:08 -07:00
Poorna Gunathilaka 0177764a03 Explorer: Fuzzer issue around integer overflow (#2737)
Closes #2732
2023-04-06 16:54:58 -07:00
Amr Hesham 87df7f7c43 Explorer: Fuzzer issue around infinite recursion (#2741)
I limited the stack size to 1K we can change it or make it dynamic from CLI later

Closes #2733
2023-04-06 16:50:02 -07:00
Adrien Leravat 8cb3f00f1b Explorer: fix assignment error typo (#2746)
Fix typo in error message from expression categories renaming
2023-04-06 16:48:51 -07:00
Adrien Leravat 65578bd8db Documentation: fix typo (#2742) 2023-04-05 16:17:03 -07:00
josh11b ee22d562bb No longer accepting GSoC applications (#2743)
Update README to drop language about applying.
2023-04-05 16:16:36 -07:00
Adrien Leravat d0645c6a85 Explorer: rename value categories to expression categories (#2744)
Rename value categories to expression categories based on [Discord discussion](https://discord.com/channels/655572317891461132/753021843459538996/1092924035517665332) regarding naming and behavior.

>* let expression -> value expression
>* var expression -> reference expression
>* located expression -> initializing expression
>So:
>- "value expressions" produce values (with no associated location). "reference expressions" produce a location of an existing value. "initializing expressions" take a location and initialize it.
>- A let binding is initialized by a value expression, because lets represent values (with category conversions performed as needed, but if a conversion is performed from a different category of expression, the value of the object is pinned for the lifetime of the let).
>- A var binding is initialized by an initializing expression, without performing a copy (with category conversions performed as needed, calling a copy constructor if the initializer is a different expression category).
>- The & operator requires a reference expression, and it's an error to give it other kinds.
>- The left-hand side of . requires a value expression when calling a function with a non-addr receiver, and requires a reference expression when calling a function with an addr receiver (it's an error to give it a value expression, and for an initializing expression, a temporary is materialized).

Changes
* Rename "value category" to "expression category"
* Rename Var and Let value categories to Value, Reference, and Initializing expression
* Rename `lvalue` to `location` (most of the time)
2023-04-05 16:16:10 -07:00
Prabhat Sachdeva 3f1515af55 Change InstantiateType to be an Action (#2660)
Added an alternative way of Instantiating types (it was previously done using `InstantiateType` method).
Created an `Action` called `TypeInstantiationAction` and changed most of the code that directly invokes `InstantiateType` to instead spawn a new `TypeInstantiationAction`.

Relates to [#2594 ](https://github.com/carbon-language/carbon-lang/issues/2594)
2023-04-03 17:15:24 -07:00
Aswin Shailajan b956d0603f Updated words.md with info on NFC (#2681) 2023-04-03 11:17:48 -07:00
Amr Hesham 29cdeb0d6b Explorer: Fuzzer issue around divide-by-zero (#2735)
fail with a runtime error, preventing the divide-by-zero from actually running.

Issue #2731
2023-03-31 20:53:26 -07:00
Jon Ross-Perkins a905cdea30 Improve parsing of invalid expressions. (#2726)
This addresses crashes for infix operator expressions, but the approach should more generally yield balanced parsed trees.
2023-03-31 20:51:59 -07:00
Jon Ross-Perkins 7824e9618c Consolidate towards ImplicitAs handling. (#2719)
This eliminates the older TryTypeConversion approach in favor of the ImplicitAs logic. This makes `return {}` work correctly.
2023-03-31 08:11:17 -07:00