mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
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.
This commit is contained in:
parent
43d932df3b
commit
335265e15c
12 changed files with 90 additions and 56 deletions
|
@ -1207,7 +1207,7 @@ pub fn canonicalize_expr<'a>(
|
|||
output,
|
||||
)
|
||||
}
|
||||
ast::Expr::Dbg(_, _) => {
|
||||
ast::Expr::Dbg(_) | ast::Expr::DbgStmt(_, _) => {
|
||||
internal_error!("Dbg should have been desugared by now")
|
||||
}
|
||||
ast::Expr::LowLevelDbg((source_location, source), message, continuation) => {
|
||||
|
@ -2476,7 +2476,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
|
|||
| ast::Expr::OpaqueRef(_)
|
||||
| ast::Expr::MalformedClosure => true,
|
||||
// Newlines are disallowed inside interpolation, and these all require newlines
|
||||
ast::Expr::Dbg(_, _)
|
||||
ast::Expr::DbgStmt(_, _)
|
||||
| ast::Expr::LowLevelDbg(_, _, _)
|
||||
| ast::Expr::Defs(_, _)
|
||||
| ast::Expr::Expect(_, _)
|
||||
|
@ -2486,6 +2486,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
|
|||
| ast::Expr::Str(StrLiteral::Block(_))
|
||||
| ast::Expr::SpaceAfter(_, _) => false,
|
||||
// These can contain subexpressions, so we need to recursively check those
|
||||
ast::Expr::Dbg(expr) => is_valid_interpolation(&expr.value),
|
||||
ast::Expr::Str(StrLiteral::Line(segments)) => {
|
||||
segments.iter().all(|segment| match segment {
|
||||
ast::StrSegment::EscapedChar(_)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue