Skip to content

Commit

Permalink
Don't generalize list literal types.
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Oct 25, 2023
1 parent cb1230e commit 6e9b980
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/nodes/Evaluate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import UnexpectedTypeInput from '@conflicts/UnexpectedTypeInput';
import type Node from './Node';
import type Conflict from '../conflicts/Conflict';
import evaluateCode from '../runtime/evaluate';
import UnionType from './UnionType';

test.each([
[
Expand Down Expand Up @@ -143,7 +144,7 @@ test('Test generics', () => {
// Infer the type from an input.
testTypes('ƒ test⸨T⸩(a•T) a\ntest(1)', NumberType);
// Infer from lists
testTypes('[ 1 2 3 ].random()', NumberType);
testTypes('[ 1 2 3 ].random()', UnionType);
// Infer from sets
testTypes('{ 1 2 3 }.remove(1)', SetType);
// Infer from map higher order function
Expand Down
5 changes: 1 addition & 4 deletions src/nodes/ListLiteral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ export default class ListLiteral extends Expression {

computeType(context: Context): Type {
// Strip away any concrete types in the item types.
return ListType.make(
this.getItemType(context),
this.values.length
).generalize(context);
return ListType.make(this.getItemType(context), this.values.length);
}

computeConflicts(): Conflict[] {
Expand Down
2 changes: 1 addition & 1 deletion static/examples/Maze.wp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Maze
``A maze is a 2D grid of emoji, with some functions for checking the state at particular grid postions.
Mazes are generated randomly.``/en
•Maze() (
grid:
grid•[[''|ø]]:
[
[ '🎬' '❤️' '❌' ø ø]
[ '❤️' ø ø ø ø]
Expand Down

0 comments on commit 6e9b980

Please sign in to comment.