diff --git a/CHANGELOG.md b/CHANGELOG.md index c65cb563a9..0e38574994 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * Handling of module-dependent size expressions in type abbreviations (#2209). +* A `let`-bound size would mistakenly be in scope of the bound + expression (#2210). + ## [0.25.26] ### Fixed diff --git a/src/Language/Futhark/TypeChecker/Names.hs b/src/Language/Futhark/TypeChecker/Names.hs index 473b535908..a0f3087203 100644 --- a/src/Language/Futhark/TypeChecker/Names.hs +++ b/src/Language/Futhark/TypeChecker/Names.hs @@ -338,8 +338,8 @@ resolveAppExp (Match e cases loc) = resolvePat p $ \p' -> CasePat p' <$> resolveExp body <*> pure cloc resolveAppExp (LetPat sizes p e1 e2 loc) = do checkForDuplicateNames (map sizeBinderToParam sizes) [p] + e1' <- resolveExp e1 resolveSizes sizes $ \sizes' -> do - e1' <- resolveExp e1 resolvePat p $ \p' -> do e2' <- resolveExp e2 pure $ LetPat sizes' p' e1' e2' loc diff --git a/tests/shapes/letshape12.fut b/tests/shapes/letshape12.fut new file mode 100644 index 0000000000..e65b3bbcc0 --- /dev/null +++ b/tests/shapes/letshape12.fut @@ -0,0 +1,7 @@ +-- #2210 +-- == +-- error: Unknown name "n" + +def f : [42]f32 = + let [n] turtle: f32 -> [n]f32 = \(x: f32) -> replicate n x + in turtle 42