Commit graph

740 commits

Author SHA1 Message Date
Anton-4
02cf61f985
Merge pull request #7038 from mulias/expr-dbg
Support `dbg` in expressions
2024-09-02 13:30:32 +02:00
Anton-4
3c679f6338
Merge branch 'main' into lower-module-params 2024-08-30 16:29:46 +02:00
Elias Mulhall
56c5b790a7 Refactor dbg expression parsing to work more like function application
Instead of parsing dbg with an expression block, parse the dbg keyword
with no additional arguments. This way the parser treats dbg just like a
variable in function application. We desugar by pattern matching on
`Apply(Dbg, args, called_via)` nodes. This changes the output of syntax
tests since the initial AST is different, but does not change the output
of can or mono.

Add two new errors for dbg in expression position with either no args or
too many args. This is similar to the error behavior of `crash`.

Continue to parse dbg statements with an expression block, as before.
2024-08-29 15:36:48 -04:00
Elias Mulhall
fefb4a3115 Don't use debug formatting to convert Variable into string 2024-08-28 12:51:02 -04:00
Elias Mulhall
7a07f13f31 Test dbg expr desugaring 2024-08-28 12:16:22 -04:00
Elias Mulhall
4cf214869e Extract helper functions for desugaring dbg statements and expressions
This reduces code duplication because `desugar_dbg_expr` calls
`desugar_dbg_stmt`. We will also reuse these functions for desugaring
dbg in pipelines.
2024-08-28 11:53:44 -04:00
Elias Mulhall
9dae102603 Allow dbg expression inside string interpolation 2024-08-28 11:53:44 -04:00
Elias Mulhall
220bb55048 Desugar dbg expression into a dbg statement
Use a temporary variable to print and then return the body of the dbg
expression.
2024-08-28 11:53:44 -04:00
Elias Mulhall
335265e15c Parse dbg in expression position
Add dbg parsing logic everywhere we parse normal expressions. Add
special case to statement parsing to handle a series of statements
ending in a `dbg` in expression position.

Rename existing `dbg_help` function to `dbg_stmt_help`, similarly rename
syntax snapshot test files to specify which ones are for dbg statements.
2024-08-28 11:53:44 -04:00
Elias Mulhall
43d932df3b Update parser AST to support dbg as both a statment and expression
Make `Expr::Dbg` node specific to dbg expressions, add `Expr::DbgStmt`
for dbg statements. Debug expressions don't have a continuation branch.
Support formatting both kinds of `Dbg` nodes.
2024-08-28 11:53:44 -04:00
Elias Mulhall
a16f757164 Pass var_store into desugar_expr so that desugaring may generate fresh vars 2024-08-28 11:53:44 -04:00
Agus Zubiaga
287a8fa2e7
Merge branch 'main' into lower-module-params 2024-08-28 08:50:40 -03:00
Agus Zubiaga
49a6b1bfba
Capture whole params record when needed 2024-08-27 11:20:59 -03:00
Agus Zubiaga
80770fae11
Handle aliases at call instead 2024-08-27 02:51:23 -03:00
Agus Zubiaga
36df43fadc
Handle simple aliased fn in params value def 2024-08-27 01:27:54 -03:00
Agus Zubiaga
b667753a32
Capture import params def 2024-08-26 23:31:42 -03:00
Agus Zubiaga
2f4e80b696
Gather arities while building can declarations 2024-08-26 22:39:35 -03:00
Sam Mohr
12df3a04de
Merge attempt 2024-08-19 23:34:05 -07:00
Sam Mohr
7c7485bb04
Merge pull request #7005 from smores56/deprecate-backpassing
Deprecate backpassing to prepare for eventual removal
2024-08-18 08:08:29 -04:00
Agus Zubiaga
50887e6265
Capture params in nested defs 2024-08-17 16:13:44 -03:00
Agus Zubiaga
519ff56a85
Create can::module::ModuleParams for convenience 2024-08-17 13:10:37 -03:00
Agus Zubiaga
e80e3e5b2d
Convert top-level value def to fn taking params 2024-08-17 11:21:21 -03:00
Sam Mohr
50f6e11423
Deprecate backpassing to prepare for eventual removal 2024-08-16 22:36:04 -07:00
Agus Zubiaga
7a8b9f7d6d
Add variable to ParamsVar 2024-08-16 20:54:16 -03:00
Sam Mohr
209d78f72c
Minor formatting fix 2024-08-16 01:52:56 -07:00
Sam Mohr
b1a972ab21
Implement &foo record updater syntax sugar 2024-08-16 01:41:59 -07:00
Sam Mohr
0fd0cc11aa
Format code 2024-08-14 22:26:32 -07:00
Sam Mohr
3bc5c1dc12
Combine ! and ? into single TrySuffix AST node 2024-08-14 22:14:08 -07:00
Sam Mohr
7e72541a79 Merge branch 'main' into builtin-task 2024-08-12 23:12:38 -07:00
Agus Zubiaga
762799052e
Merge branch 'main' into typecheck-module-params 2024-08-07 18:55:33 -03:00
Sam Mohr
00bc699642
Add syntax tests for record builder 2024-08-06 22:49:35 -07:00
Sam Mohr
cb8040f629
Ignore underscore-prefixed fields in record builders 2024-08-06 22:49:35 -07:00
Sam Mohr
66cf946965 Fix PR comments 2024-08-03 04:37:31 -07:00
Sam Mohr
8288af3156
Merge branch 'main' into builtin-task 2024-07-31 13:36:32 -07:00
Aidan
4bf5154610 remove spaces_middle from crates/compiler/can/src/desugar.rs 2024-07-29 13:11:57 -04:00
Aidan
ddb58a2cd5 spaces_middle -> lines_between 2024-07-29 13:06:48 -04:00
Aidan
91fdd903e7 comment -> spaces_middle 2024-07-29 10:04:32 -04:00
Aidan
125990855f Merge branch 'main' into store-all-space-between-annotation-body 2024-07-29 09:46:05 -04:00
Luke Boswell
eca453d07f
Merge remote-tracking branch 'remote/main' into builtin-task 2024-07-29 16:05:51 +10:00
Aidan
62dbe9fb53 update snapshots 2024-07-27 17:19:02 -04:00
Joshua Warner
4f32f43048
Implement block / indent based parsing
... and enforce that defs can only occur in blocks (or, inside parenthesized expressions)
2024-07-27 13:34:16 -07:00
Aidan
05f4062c69 clippy 2024-07-27 12:25:24 -04:00
Aidan
3c78b4fb86 functional changes 2024-07-27 12:16:04 -04:00
Kiryl Dziamura
7aa31a1639
code cleanup 2024-07-23 23:16:50 +02:00
Kiryl Dziamura
692f8e8090
remove redundant dependency 2024-07-23 23:16:50 +02:00
Kiryl Dziamura
863fb3b29f
remove obsolete test 2024-07-23 23:16:50 +02:00
Kiryl Dziamura
1f65d95e09
update suffixed tests snapshots 2024-07-23 23:16:49 +02:00
Kiryl Dziamura
10bdabf52e
better desugared idents 2024-07-23 23:16:49 +02:00
Kiryl Dziamura
9a37aeb82f
fix types propagation 2024-07-23 23:16:49 +02:00
Kiryl Dziamura
4d5586b68a
simplify identity unwrap 2024-07-23 23:16:49 +02:00