Commit Graph
496 Commits
Author SHA1 Message Date
Jon Meow 18e3969ded Prevent clang-tidy from changing classof (#719) 2021-08-09 08:19:39 -07:00
Jon MeowandGeoff Romer dbcd6ad20d Switch Expression to use inheritance+cast (#712)
Co-authored-by: Geoff Romer <gromer@google.com>
2021-08-06 15:43:25 -07:00
Jon Meow 4e0307efbc Switch Member to use inheritance+cast (#713) 2021-08-06 15:27:31 -07:00
Jon Meow 6164cdfd6d Verify that provision/omission of return types matches (#717)
This is finishing #678
2021-08-06 15:18:39 -07:00
Jon Meow 4b2346cfcd Switch Action to use inheritance+cast (#711) 2021-08-06 15:14:29 -07:00
Jon Meow c1148caf7d Switch Declaration to use inheritance+cast (#714) 2021-08-06 14:57:44 -07:00
Jon Meow 7c03858b55 Explanatory FATAL comment (#716)
Oversight from #704, I'd had this change in the client but missed it because I ran git add in the wrong spot.
2021-08-06 14:57:21 -07:00
Jon MeowandGeoff Romer 642addfe48 Fix caching and correctness of --update_goldens (#709)
- `PATH` is a caching issue, as commented.
- `exec.map` is a correctness issue, the reference to `test` was incorrect on threading so it wasn't updating all tests.

Co-authored-by: Geoff Romer <gromer@google.com>
2021-08-06 13:16:43 -07:00
Jon Meow 2e9e4f4cb3 Migrate remaining exits to FATAL_*_ERROR calls (#704)
Adds FATAL for things that are most likely programming errors in executable_semantics.
2021-08-06 13:06:25 -07:00
Jon Meow 5749413b28 Add TupleValue::Empty for the common empty tuple case (#708) 2021-08-06 10:06:35 -07:00
Jon Meow f7d8b7f2e2 Add Dump to Pattern (#715) 2021-08-06 10:05:00 -07:00
Jon MeowandGeoff Romer 2620ba066d Move Int parsing to i32 for #543 (#700)
Note this doesn't support other sizes or types, it just errors on them.

Co-authored-by: Geoff Romer <gromer@google.com>
2021-08-05 09:34:12 -07:00
Jon Meow 7e91fbc276 Switch Value to use the inherit/cast model (#703) 2021-08-05 08:34:08 -07:00
Jon Meow 3116c6ff5d Update vscode recommendations (#707)
I think the MS C++ extension is what was causing vscode to hang for me. I've been trying clangd and it seems to work better.

yash is syntax highlighting for ypp/lpp. The builtin markdown support's gotten better, so I'm removing the non-standard recommendation.
2021-08-05 08:18:31 -07:00
Jon Meow 04a7e53c7e Pin bazeliskrc to 4.1.0 which supports m1 (#705)
bazelbuild/bazel#11628 is in Release 4.1 - May 2021 #13099

Pin vs rm for build repeatability.
2021-08-05 08:17:48 -07:00
Jon Meow 7934630abd Small pre-commit autoupdate (#706) 2021-08-04 16:09:27 -07:00
josh11bandRichard Smith 48b7dc3b81 :! generic syntax (#676)
This implements decision #565 to use `T:! Type` to declare generic parameters, and `template T:! Type` for template parameters.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-08-04 14:27:11 -07:00
Richard SmithandChandler Carruth 86ae4c6053 And, or, not (#680)
Proposal: use `and`, `or`, and `not` keywords in place of `&&`, `||`, `!`.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-08-03 15:37:18 -07:00
Geoff Romer de91afcf25 Rename ::yy::parser to ::Carbon::Parser. (#697)
Not only is this more consistent with our style rules, it lets us omit a lot of noisy qualifiers in parser.ypp
2021-08-03 12:09:42 -07:00
38eb2c0d2f Low context-sensitivity principle (#646)
Establish a principle that understanding the meaning and performance should not depend on expensive context, and explain what makes context expensive.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-08-03 10:20:46 -07:00
Jon Meow 0ca914a17a Remove outdated bison comment (#695) 2021-08-02 18:26:27 -07:00
Jon Meow 6ae9cc3cf8 Add support for return; (#678)
This creates a ReturnExpression. A separate change should enforce that an implicit return of `()` is only allowed in functions that have an implicit return type of `()`, and I think the structure taken here should ease that.
2021-08-02 16:30:08 -07:00
Richard Smith b1993a6cd0 [toolchain] Parsing support for tuple literal syntax. (#694)
For now, we permit non-empty tuples to have trailing commas, and require
a trailing comma if there's exactly one list element. The exact rule
here has not yet been decided.
2021-08-02 16:18:18 -07:00
Richard SmithandChandler Carruth a83c22288f [toolchain] Implement lexing and parsing support for #543. (#693)
Lex [iuf][1-9][0-9]* as a new kind of "sized type literal" token. When
parsing that token, form a literal expression.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-08-02 15:37:43 -07:00
Jon Meow 9829f188b7 Move all new's to global_arena, and remove ASAN disabling (#690)
Note this changes identifiers from char* to string to avoid malloc.

Fixes #580
2021-08-02 11:08:22 -07:00
Richard Smith f1028fcc27 [toolchain] Implement #623: require braces.
For error recovery, allow the braces around the controlled statement of
an `if`, `while`, or similar to be omitted. Remove support for nested
code blocks as this conflicts with struct literal syntax.
2021-07-30 18:27:52 -07:00
jonmeow 91512e90e7 Fix tests affected by pattern change 2021-07-30 17:49:37 -07:00
Jon Meow f2db4e2e9f Fix tests.py paths and use pre-commit to guard against lost tests (#689)
- In pre-commit-config, add a run of `--update_list`. I'm doing this because I noticed (on running tests.py) that we'd lost track of a few tests.
- In tests.py, the paths affect bison output where the path to the file is mentioned. This shift should make `--update_goldens` more reliable.
2021-07-30 17:04:49 -07:00
Geoff RomerandJon Meow 6ac3adfa53 Factor out a Pattern sum type from Expression (#685)
`Pattern` is intended to pilot some changes I would like to apply to all our sum types:
- The alternatives are expressed as derived classes rather than members of a `std::variant`.
- The alternatives are classes in the [style guide sense](https://google.github.io/styleguide/cppguide.html#Structs_vs._Classes), meaning they can have invariants, but can't have public data members.
- Creating an object is expressed using a constructor rather than a factory function.
- Accessing an alternative is expressed as a cast (using LLVM's RTTI system) rather than `std::get` or a `Get` method.

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
2021-07-30 12:24:12 -07:00
Jon Meow b08f6bb0f1 Add a global arena to start cleaning up ASAN errors (#687) 2021-07-30 10:56:53 -07:00
Jon Meow 2f023b3479 Flesh out the conditionals doc (#655) 2021-07-29 15:31:36 -07:00
Geoff Romer a8f56797b8 Add Dump methods to printable types. (#681) 2021-07-29 14:17:35 -07:00
Jon Meow 61abc44aef Mention the RFC project column in docs (#688)
Nothing is automating "ready for review" unfortunately, but the lack of RFC mention seems like a clear miss.
2021-07-29 10:57:21 -07:00
Jon Meow a930717202 Require braces on control flow statements (#683)
This implements #623
2021-07-28 10:55:14 -07:00
Jon MeowandChandler Carruth f0af3cb795 Switch from llvm::errs()+exit() to FATAL_USER_ERROR() stream-based handling. (#670)
This is intended to:

- Standardize use of line_num (and highlight where no line_num is available).
- Standardize indications of runtime/compilation errors.
- Make it incrementally easier to write new errors.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-07-28 10:47:33 -07:00
Geoff Romer dcc694c2e0 Auto-enable pretty-printing of libcxx in gdb. (#679) 2021-07-28 09:42:04 -07:00
Jon Meow 96a226ec84 Use stale workflow to archive inactive PRs/issues (#659)
- Automatically mark issues/PRs `inactive` after 90 days without comments
- Archive PRs (only) after 14 more days
- Adding "long term" for issues which can't be resolved in a few months, but shouldn't be marked `inactive`.
2021-07-27 14:08:25 -07:00
Geoff Romer fb0c0b63bf Fix match bug when no case matches (#677) 2021-07-27 11:14:10 -07:00
Jon MeowandGeoff Romer 165651c75c Add script to automate mass test updates (#674)
Trying to simplify the process of updating golden output, and ensuring that we aren't missing any tests. With this script, it should be roughly "Add the .carbon file, then run tests.py --update_all"

Co-authored-by: Geoff Romer <gromer@google.com>
2021-07-26 14:57:00 -07:00
a725ae214d Add design style guide and a description of what belongs in the design versus in a proposal document. (#649)
Expand the description of the structure of a proposal PR. Clarify that
the full PR is the proposal, not only the P-numbered document. Start a
design style guide and use it to describe which parts of a proposal
should not end up in the design.

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-07-26 11:58:40 -07:00
Geoff Romer d4ed6b1083 Enable some additional warnings. (#675) 2021-07-26 11:42:38 -07:00
Jeremy G. Siek a1c164f598 added a test for definition-side checking with expected failure (#673) 2021-07-23 11:42:07 -04:00
Jon Meow edbc3f7716 Use llvm::ListSeparator for simpler separators (#671)
I was looking for something like this, I think it's a straightforward simplification for code. Internally, it handles skipping the separator on the first print.

See the bottom of: https://llvm.org/doxygen/StringExtras_8h_source.html
2021-07-23 08:39:58 -07:00
Jon Meow f35cda7a99 Move ASAN_OPTIONS to executable_semantics, local to the leak. (#672) 2021-07-23 08:37:59 -07:00
Jeremy G. SiekandJon Meow 864b3bde02 Generic functions, first baby step (#658)
* generic functions: progress on parser and AST

* finished first baby step

* revisions based on reviews

* Update executable_semantics/interpreter/interpreter.cpp

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>

* Symbol => VariableType

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
2021-07-22 15:16:56 -04:00
cc56afb79e Require braces (#623)
Require braces, never optional, particularly in control flow like `if`/`else`.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-07-22 10:42:54 -07:00
Jon Meow 034f3600e3 Add a FatalUserError macro to help print user-caused errors. (#668) 2021-07-21 12:38:56 -07:00
Jon Meow f3cbfc04c6 Move tracing_flag into a common directory (#669)
Intended to combine well with #668, so neither is alone.
2021-07-21 09:57:54 -07:00
Geoff Romer 08a2d44570 Simplify the API and implementation of Stack (#667) 2021-07-20 14:27:41 -07:00
Jon Meow 8fccecadeb Refactor output to be more streaming-focused. (#666)
- Switch code to llvm::raw_ostream as part of standardizing output forms.
    - Preferring llvm::raw_ostream over std::ostream because other tooling code should be expected to rely on llvm more closely, and an overall preference towards library consistency.
    - There are a couple spots in syntax/ that still use std streams, but I'd prefer to take a separate PR to see how best to address those.
    - std::boolalpha doesn't work with llvm, so I've implemented equivalent in a couple places (not enough that it felt like worth making a helper function).
- Implement Print(ostream) as consistently as we can, as an instance member.
    - This facilitates the use of the common/ostream.h template to provide operators.
    - Preferring this approach so that Print is easily accessible via gdb, per suggestion on #executable-semantics.
- Switch code currently calling `type->Print(ostream)` to instead do `ostream << *type`.
- Remove the unused `PrintTypeEnv`, nothing used it and the declaration didn't match the definition.
2021-07-20 13:16:48 -07:00