Browse Source

Fix bug where lambda required an application

master
Dylan Baker 5 years ago
parent
commit
7bbcd1de4f
2 changed files with 13 additions and 1 deletions
  1. 1
    1
      src/parser.js
  2. 12
    0
      test/parserTest.js

+ 1
- 1
src/parser.js View File

@@ -142,7 +142,7 @@ module.exports = class Parser {
142 142
 
143 143
     return new AST.Lambda({
144 144
       parameters: parameters,
145
-      body: this.form(),
145
+      body: this.expr(),
146 146
     })
147 147
   }
148 148
 

+ 12
- 0
test/parserTest.js View File

@@ -115,3 +115,15 @@ test('missing close quote returns an error', t => {
115 115
     }),
116 116
   )
117 117
 })
118
+
119
+test('allow returning atomic value from lambda', t => {
120
+  t.plan(1)
121
+  const tree = helpers.parse('(lambda (x) x)')
122
+
123
+  t.deepEqual(tree, [
124
+    new AST.Lambda({
125
+      parameters: [new AST.Identifier({ name: 'x' })],
126
+      body: new AST.Identifier({ name: 'x', line: 1 }),
127
+    }),
128
+  ])
129
+})

Loading…
Cancel
Save