Commit Graph
1293 Commits
Author SHA1 Message Date
Jon Ross-Perkins 495d75a394 Switch to clang-format 14.0.6 (#2253)
14.0.6 is the latest release at https://pypi.org/project/clang-format/#history, hopefully 15.0.0 will be out soon. Looks like ssciwr/clang-format-wheel#49 is noting issues for this particular release process though.
2022-10-06 12:19:24 -07:00
Jon Ross-Perkins 0b9bda10b7 Refactor common main logic (#2260)
1) toolchain and explorer use the same working dir logic, share it
2) explorer's carbon.cpp and main_bin.cpp use the same relative path logic, share it
3) You can append a longer path in one call with the right kind of iterator
4) Fix what's maybe a bug in passing `relative_prelude_path.str()` to `cl::init`
5) Collapse Main and ExplorerMain to avoid passing more parameters between
2022-10-05 17:34:04 -07:00
Richard Smith 4785201d80 Remove SetConstantValue and collection of a set of constants. (#2259)
The only usage of this set is to include this list in trace output when
tracing type-checking of patterns. But that in turn seems arbitrary and
not useful.
2022-10-05 17:30:27 -07:00
Geoff Romer be961dca3a Update and clarify error documentation (#2262) 2022-10-05 13:23:39 -07:00
Kareem Ergawyandergawy dc43767b16 Fix a small typo in the driver help message. (#2261)
The help message was using `_`s while the actual sub-commands use `-`.

Co-authored-by: ergawy <kareem.ergawy@guardsquare.com>
2022-10-05 09:23:18 -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
Richard Smith c703c89658 Allow explorer to be run directly from the bazel build directory. (#2257)
Previously explorer worked under `bazel run` but not when run directly, because it was finding the prelude relative to the current working directory. Now it looks for it relative to the location of the binary, so it works both when run directly and when run with `bazel run`.
2022-10-04 14:48:15 -07:00
Richard Smith e172c0a581 Add test for member access into symbolic witness. (#2256)
Add missing test requested by @jonmeow in review of #2250.
2022-10-04 12:51:02 -07:00
Jon Ross-Perkins 1524becc4f Make the toolchain binary work better with bazel run. (#2252)
Makes the toolchain binary work with `bazel run` and relative paths, such as:

bazel run //toolchain/driver:carbon -- dump semantics-ir empty.carbon
2022-10-04 12:37:18 -07:00
Richard Smith 2340cb6703 Build value representations for all kinds of witness (#2250)
Instead of forming a `SymbolicWitness` that contains an `Expression` when we can't directly resolve a witness to an `impl`, form different kinds of `Witness` values for the various situations:

- A `BindingWitness` witnesses that a type implements a constraint by reference to an `ImplBinding`.
- A `ConstraintWitness` witnesses that a type implements a constraint by reference to witnesses for each of the impl constraints within the constraint.
- A `ConstraintImplWitness` witnesses that a type implements a constraint by reference to a larger constraint which contains that constraint as an impl constraint.

Remove `SymbolicWitness` values and `InstantiateImpl` expressions, which are now unused. In order to remove the final usage of `SymbolicWitness`, I fixed a TODO to give `Self` the proper type within an interface declaration. I don't think this is an observable change.

No functional change intended.
2022-10-04 12:14:52 -07:00
Adrien Leravat 8e8e8ced60 docs: fix code sample typo (#2254)
Fix small typo in classes documentation
Added to a decicated PR to keep things orderly
2022-10-04 08:57:10 -07:00
Richard Smith 04d49cebd8 Consistently use a Witness rather than an expression to represent a possibly-symbolic witness. (#2245)
Previously we used an expression in some places and a `Witness` values in others. The eventual goal is to make `Witness` values behave like other symbolic values such as `NominalClassType`, but the first step is to consistently treat them like values rather than expressions.

No functionality change intended.
2022-10-03 14:00:41 -07:00
Jon Ross-Perkins c198dafbe8 Switch semantics-ir tests to lit (#2224)
This builds on semantics-ir lit support added by #2222
 
The googletest setup was feeling cumbersome, especially as I'm thinking about how to add more testing: I feel like I'm wrestling with the infrastructure.

The `[[ID1]]` and so on in tests is one advantage of switching: it's easier to do matching of IDs for verification. This is also more agnostic about the numbers than before, something which I'm concerned will be important as I think about builtins.

To explain my builtins thought, I think that needs to be another SemanticsIR with basically names pointing at builtin things. But this (a) creates multiple SemanticsIRs, which would confuse the current singleton approach and (b) starts creating more fluctuation for IDs, potentially impacting the numbers used (also, chandlerc's suggested pointers for some use-cases).

Overall it felt like I was heading towards a situation with googletest where writing the tests would be really difficult, and it was adding to my hesitance to write more code in the toolchain. I'm hoping this acts as a simplification.

Note, the "cp" commit has some incremental changes to googletest that I'd considered for making it easier to add matchers, but ultimately I ended up with this outcome.
2022-10-03 13:09:04 -07:00
8d5d48a4a7 [toolchain][parser] Parse for statement. (#2180)
Summary:

Add support for parsing `for` loops.

Co-authored-by: ergawy <kareem.ergawy@guardsquare.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-10-03 08:36:19 -07:00
Jon Ross-Perkins 11a138b467 Fix things up to make running clang-tidy easier. (#2246)
run_clang_tidy.py (the clang-tools-extras version) is parallel so should be feasible to work with. I'm trying to codify this mainly because finding out the right invocation can be difficult.

This fixes some loading of re2 and proto that's started to become an issue.

It's hard to see actual issues because of the identifier length warning being turned off in #2244, and just general issue creep. There may be more fixes to do but this should still be an improvement.
2022-09-30 18:15:16 -07:00
Jon Ross-Perkins ba226454d0 Disable readability-identifier-length in clang-tidy (#2244)
https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-length.html

This complains about `id` which I'm using a lot and feels like a reasonable name, and honestly single-letter variable names seem reasonable in certain contexts. Trying to make this work better doesn't seem like it'll be worth the time cost.
2022-09-30 17:01:48 -07:00
Geoff Romer 96735e89b8 Clarify that l-values and r-values are expressions (#2243) 2022-09-30 13:34:11 -07:00
Jon Ross-PerkinsandRichard Smith 1e1fa9295d Rewrite contribution tools documentation (#2203)
Key rewrite points:

- Making more use of apt now, since we no longer need `brew` for llvm on Linux.
  - Gets ahead of issues with brew's llvm 15 on Linux.
- Clear list of commands for a typical setup.
- Less verbose text about various tool options (I think this was just too much).

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-09-30 13:21:27 -07:00
Geoff Romer f7fd5656f0 Remove support for curly-braced "receiver" syntax (#2220) 2022-09-30 12:36:35 -07:00
Jon Ross-Perkins 9b03367449 Remove duplicate template (#2239) 2022-09-30 10:33:11 -07:00
Jon Ross-Perkins b0060e5cfb Rename issue template yaml to yml (#2233)
The config.yaml doesn't seem to be getting seen. Judging by https://github.com/carbon-language/carbon-lang/tree/trunk/.github/ISSUE_TEMPLATE ("Customize the issue creation experience with a config.yml file.") I think yaml is allowed for a lot of things (including the templates) but not config.yml.

I'm renaming other files for consistency.
2022-09-30 10:14:04 -07:00
Jon Ross-Perkins b94c496aee Fix incomplete TODO in driver (#2231)
From #2222
2022-09-30 08:10:10 -07:00
Jon Ross-Perkins df829f9ad4 Add a doc issue template (#2234) 2022-09-29 14:58:10 -07:00
Jon Ross-Perkins 768764787f Fix x/_ and y/z in faq example. (#2230) 2022-09-29 10:52:05 -07:00
Jon Ross-Perkins af92a1d2ab Add some issue templates (#2225)
ref: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository

example of how this is supposed to look: https://github.com/flutter/flutter/issues/new/choose
2022-09-29 10:25:34 -07:00
Jon Ross-Perkins 80570e1a5b Modify the driver to support using for semantics IR testing (#2222)
This unifies `dump-tokens` and `dump-parse-tree` so that we don't keep writing basically the same code repeatedly.

I'll need to modify the output of SemanticsIR::Print more, and may soon unify printing multiple IRs this way (particularly including the builtins SemanticsIR) but this is intended to offer a starting point.

I may eventually try to unify lit.cfg.py files, but I was thinking about whether that works in various contexts we may run in and eventually decided copying the driver/testdata/lit.cfg.py file would be the easiest solution.
2022-09-28 17:40:57 -07:00
Jon Ross-Perkins 59b0ac1616 Remove copyright from PR template (#2227)
The template gets inserted into the PR description verbatim, copyright included, which wasn't my intent.
2022-09-28 16:25:03 -07:00
Jon Ross-Perkins 094408935c Add a skeletal PR template (#2226)
e.g. https://github.com/flutter/flutter/blob/master/.github/PULL_REQUEST_TEMPLATE.md

But I feel weird adding a checklist
2022-09-28 16:06:30 -07:00
Geoff Romer 9b1a32b7b7 Miscellaneous code of conduct clarifications (#2219) 2022-09-27 12:01:06 -07:00
josh11bandBarry Revzin 29d8f9845e Clarifications to "checked and template parameters" (#2216)
This attempts to address concerns that @brevzin first tried to fix in #1443 .

Co-authored-by: Barry Revzin <barry.revzin@gmail.com>
2022-09-26 16:57:03 -07:00
pmqtt cfa295c0af Feature destructor (#2116) 2022-09-26 10:11:05 -07:00
micttyl c63ae9b05d Prefix Fail to Failing Test (#2212) 2022-09-24 11:40:08 -07:00
Jon Ross-Perkins f417be79d2 Run apt-get update and install together (#2192)
This is a recommended best practice: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#apt-get
2022-09-22 15:16:17 -07:00
Jon Ross-Perkins 1248831001 Emphasize Discord for design (#2206) 2022-09-22 12:38:26 -07:00
Jon Ross-Perkins 6293610cb0 Replace dashes with underscores in llvm-patches (#2211)
Dashes in bazel package names in particular can cause problems (which renaming `llvm-patches` to `llvm_patches` will fix for me). But we've generally named files with underscores, so there's also consistency.
2022-09-22 12:37:24 -07:00
Jon Ross-Perkins c87a914bbd pre-commit update (#2210)
pre-commit autoupdate --freeze && pre-commit run -a

(no other edits, just the one version update)
2022-09-22 11:00:29 -07:00
micttyl dc4e968373 Fix Markdown (#2208)
`explicit parameter` to have its closing rendered correctly.

Change all html-like(still supported though) notations into the Markdown style.
2022-09-22 09:01:36 -07:00
josh11b e941b90ac9 Correctly remove ## TODO section from proposals (#2207)
Fix bug introduced in #2139
2022-09-22 08:20:07 -07:00
Jon Ross-Perkins 1dcd15380c Remove stacked PR notes (#2205)
chandlerc had originally added these and previously expressed being okay with removing them. They've just proven too complex to be applied; it needs to be easier for people to want to do it.
2022-09-21 16:10:36 -07:00
micttyl 804a09bccd Do not lead people to github discussion (#2204) 2022-09-21 16:06:03 -07:00
Richard Smith ff1d69232b Switch proposal link text from pNNNN to #NN for consistency (#2202)
This is the only occurrence of using pNNNN in text to refer to a Carbon proposal in the repo. This gets us closer to following https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/design_style_guide.md.
2022-09-21 10:37:07 -07:00
micttyl 2df87ddacc Include Missing Libraries (#2201)
Minor Style: non-auto to auto
2022-09-21 09:09:13 -07:00
b464a0ac3d Unused Pattern Bindings (Unused Function Parameters) (#2022)
This proposal specifies how unused pattern bindings are written in the Carbon programming language. This is a more general problem statement of "how do users specify unused function parameters" as function parameter declarations are a more specific form of pattern

Related issue #1996

Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-09-20 17:44:22 -07:00
Jon Ross-Perkins 9be6939ee9 Fix LLVM compilation issues (#2198)
We've been having issues with asan builds on linux. This change should fix all of that. A build run can be found at:
https://github.com/carbon-language/carbon-lang/actions/runs/3093378863/jobs/5005683059

(currently in progress, but I'm expecting it to succeed at this point)

It may be that the issues with asan builds were actually related to caching. That is, maybe the brew build command didn't change enough between v14 and v15 that the cache hits were still an issue. We did notice this with 15.0.0 versus 15.0.1 include paths (that is, bazel wasn't happy using the cached results of a 15.0.0 build due to the skew in include paths). In order to address this, I've added CACHE_VERSION to the remote_cache setup. I've also set up corresponding buckets in Cloud.

However, I'm also switching Linux to llvm-15 and apt. I'd originally been looking at this because the issues were linux-specific, and we've previously had linux-specific issues with Homebrew. Although it may have been the cache all along, I would prefer to keep this setup (if nothing else, it made the caching issues more obvious, even though we were still confused by the include path manifestation).
2022-09-20 14:21:02 -07:00
Jon Ross-Perkins 174aff1f2d Remove legacy mention of bazel-clang-toolchain symlink (#2190) 2022-09-19 21:34:47 -07:00
Jon Ross-Perkins 7e4e73b6c0 Specify llvm@14 (#2195)
This should be temporary while trying to diagnose why llvm@15 fails.
2022-09-19 16:20:54 -07:00
Junhee Cho 69d4363ea5 Adds division to multiplicative expression. (#2091)
* Multiplication and division have the same priority.
* A new builtin interface DivWith is added.
* In some tests expecting a compilation error (syntax error), the error
  message now says it is expecting SLASH or binary *.
2022-09-19 15:02:29 -07:00
micttyl 57cc4c6dec Include Missing Libraries (#2193)
For better:
	`<iterator>` for `std::reverse_iterator`
	`Optional.h` for `llvm::Optional`
2022-09-19 11:22:01 -07:00
Jon Ross-Perkins c8faa47f83 Add llvm to PATH instead of CC (#2189)
This helps VS Code find clangd (instead of needing to pass in clangd-15 somehow), and seems like it'll work in general.
2022-09-16 08:29:37 -07:00
Jon Ross-Perkins b80e294b6c Make structs to distinguish ID versus NodeStore index (#2171)
WDYT of this, to avoid raw int32_t indices? I was looking at the code again and found it hard to sort out. I think this doesn't have overhead.
2022-09-15 14:36:50 -07:00