KCL: No 'let' or 'const' required when declaring vars (#4063)
Previously variable declaration required a keyword, e.g. ```kcl let x = 4 const x = 4 var x = 4 ``` These were all valid, and did the exact same thing. As of this PR, they're all still valid, but the KCL formatter will change them all to just: ```kcl x = 4 ``` which is the new preferred way to declare a constant. But the formatter will remove the var/let/const keywords. Closes https://github.com/KittyCAD/modeling-app/issues/3985
This commit is contained in:
		@ -71,28 +71,28 @@ test.describe('Testing selections', () => {
 | 
			
		||||
      await u.closeDebugPanel()
 | 
			
		||||
      await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
 | 
			
		||||
      await expect(page.locator('.cm-content'))
 | 
			
		||||
        .toHaveText(`const sketch001 = startSketchOn('XZ')
 | 
			
		||||
        .toHaveText(`sketch001 = startSketchOn('XZ')
 | 
			
		||||
    |> startProfileAt(${commonPoints.startAt}, %)`)
 | 
			
		||||
 | 
			
		||||
      await page.waitForTimeout(100)
 | 
			
		||||
      await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10)
 | 
			
		||||
 | 
			
		||||
      await expect(page.locator('.cm-content'))
 | 
			
		||||
        .toHaveText(`const sketch001 = startSketchOn('XZ')
 | 
			
		||||
        .toHaveText(`sketch001 = startSketchOn('XZ')
 | 
			
		||||
    |> startProfileAt(${commonPoints.startAt}, %)
 | 
			
		||||
    |> line([${commonPoints.num1}, 0], %)`)
 | 
			
		||||
 | 
			
		||||
      await page.waitForTimeout(100)
 | 
			
		||||
      await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
 | 
			
		||||
      await expect(page.locator('.cm-content'))
 | 
			
		||||
        .toHaveText(`const sketch001 = startSketchOn('XZ')
 | 
			
		||||
        .toHaveText(`sketch001 = startSketchOn('XZ')
 | 
			
		||||
    |> startProfileAt(${commonPoints.startAt}, %)
 | 
			
		||||
    |> line([${commonPoints.num1}, 0], %)
 | 
			
		||||
    |> line([0, ${commonPoints.num1 + 0.01}], %)`)
 | 
			
		||||
      await page.waitForTimeout(100)
 | 
			
		||||
      await page.mouse.click(startXPx, 500 - PUR * 20)
 | 
			
		||||
      await expect(page.locator('.cm-content'))
 | 
			
		||||
        .toHaveText(`const sketch001 = startSketchOn('XZ')
 | 
			
		||||
        .toHaveText(`sketch001 = startSketchOn('XZ')
 | 
			
		||||
    |> startProfileAt(${commonPoints.startAt}, %)
 | 
			
		||||
    |> line([${commonPoints.num1}, 0], %)
 | 
			
		||||
    |> line([0, ${commonPoints.num1 + 0.01}], %)
 | 
			
		||||
@ -256,46 +256,46 @@ test.describe('Testing selections', () => {
 | 
			
		||||
    await page.addInitScript(async () => {
 | 
			
		||||
      localStorage.setItem(
 | 
			
		||||
        'persistCode',
 | 
			
		||||
        `const sketch001 = startSketchOn('XZ')
 | 
			
		||||
        `sketch001 = startSketchOn('XZ')
 | 
			
		||||
        |> startProfileAt([-79.26, 95.04], %)
 | 
			
		||||
        |> line([112.54, 127.64], %, $seg02)
 | 
			
		||||
        |> line([170.36, -121.61], %, $seg01)
 | 
			
		||||
        |> lineTo([profileStartX(%), profileStartY(%)], %)
 | 
			
		||||
        |> close(%)
 | 
			
		||||
const extrude001 = extrude(50, sketch001)
 | 
			
		||||
const sketch005 = startSketchOn(extrude001, 'END')
 | 
			
		||||
extrude001 = extrude(50, sketch001)
 | 
			
		||||
sketch005 = startSketchOn(extrude001, 'END')
 | 
			
		||||
  |> startProfileAt([23.24, 136.52], %)
 | 
			
		||||
  |> line([-8.44, 36.61], %)
 | 
			
		||||
  |> line([49.4, 2.05], %)
 | 
			
		||||
  |> line([29.69, -46.95], %)
 | 
			
		||||
  |> lineTo([profileStartX(%), profileStartY(%)], %)
 | 
			
		||||
  |> close(%)
 | 
			
		||||
const sketch003 = startSketchOn(extrude001, seg01)
 | 
			
		||||
sketch003 = startSketchOn(extrude001, seg01)
 | 
			
		||||
  |> startProfileAt([21.23, 17.81], %)
 | 
			
		||||
  |> line([51.97, 21.32], %)
 | 
			
		||||
  |> line([4.07, -22.75], %)
 | 
			
		||||
  |> lineTo([profileStartX(%), profileStartY(%)], %)
 | 
			
		||||
  |> close(%)
 | 
			
		||||
const sketch002 = startSketchOn(extrude001, seg02)
 | 
			
		||||
sketch002 = startSketchOn(extrude001, seg02)
 | 
			
		||||
  |> startProfileAt([-100.54, 16.99], %)
 | 
			
		||||
  |> line([0, 20.03], %)
 | 
			
		||||
  |> line([62.61, 0], %, $seg03)
 | 
			
		||||
  |> lineTo([profileStartX(%), profileStartY(%)], %)
 | 
			
		||||
  |> close(%)
 | 
			
		||||
const extrude002 = extrude(50, sketch002)
 | 
			
		||||
const sketch004 = startSketchOn(extrude002, seg03)
 | 
			
		||||
extrude002 = extrude(50, sketch002)
 | 
			
		||||
sketch004 = startSketchOn(extrude002, seg03)
 | 
			
		||||
  |> startProfileAt([57.07, 134.77], %)
 | 
			
		||||
  |> line([-4.72, 22.84], %)
 | 
			
		||||
  |> line([28.8, 6.71], %)
 | 
			
		||||
  |> line([9.19, -25.33], %)
 | 
			
		||||
  |> lineTo([profileStartX(%), profileStartY(%)], %)
 | 
			
		||||
  |> close(%)
 | 
			
		||||
const extrude003 = extrude(20, sketch004)
 | 
			
		||||
const pipeLength = 40
 | 
			
		||||
const pipeSmallDia = 10
 | 
			
		||||
const pipeLargeDia = 20
 | 
			
		||||
const thickness = 0.5
 | 
			
		||||
const part009 = startSketchOn('XY')
 | 
			
		||||
extrude003 = extrude(20, sketch004)
 | 
			
		||||
pipeLength = 40
 | 
			
		||||
pipeSmallDia = 10
 | 
			
		||||
pipeLargeDia = 20
 | 
			
		||||
thickness = 0.5
 | 
			
		||||
part009 = startSketchOn('XY')
 | 
			
		||||
  |> startProfileAt([pipeLargeDia - (thickness / 2), 38], %)
 | 
			
		||||
  |> line([thickness, 0], %)
 | 
			
		||||
  |> line([0, -1], %)
 | 
			
		||||
@ -315,7 +315,7 @@ const part009 = startSketchOn('XY')
 | 
			
		||||
  |> line([0, pipeLength], %)
 | 
			
		||||
  |> angledLineToX({ angle: 60, to: pipeLargeDia }, %)
 | 
			
		||||
  |> close(%)
 | 
			
		||||
const rev = revolve({ axis: 'y' }, part009)
 | 
			
		||||
rev = revolve({ axis: 'y' }, part009)
 | 
			
		||||
`
 | 
			
		||||
      )
 | 
			
		||||
    }, KCL_DEFAULT_LENGTH)
 | 
			
		||||
@ -364,7 +364,7 @@ const rev = revolve({ axis: 'y' }, part009)
 | 
			
		||||
    await page.waitForTimeout(200)
 | 
			
		||||
 | 
			
		||||
    await expect(u.codeLocator).not.toContainText(
 | 
			
		||||
      `const rev = revolve({ axis: 'y' }, part009)`
 | 
			
		||||
      `rev = revolve({ axis: 'y' }, part009)`
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    // DELETE PARENT EXTRUDE
 | 
			
		||||
@ -378,9 +378,9 @@ const rev = revolve({ axis: 'y' }, part009)
 | 
			
		||||
    await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
 | 
			
		||||
    await page.waitForTimeout(200)
 | 
			
		||||
    await expect(u.codeLocator).not.toContainText(
 | 
			
		||||
      `const extrude001 = extrude(50, sketch001)`
 | 
			
		||||
      `extrude001 = extrude(50, sketch001)`
 | 
			
		||||
    )
 | 
			
		||||
    await expect(u.codeLocator).toContainText(`const sketch005 = startSketchOn({
 | 
			
		||||
    await expect(u.codeLocator).toContainText(`sketch005 = startSketchOn({
 | 
			
		||||
       plane: {
 | 
			
		||||
         origin: { x: 0, y: -50, z: 0 },
 | 
			
		||||
         x_axis: { x: 1, y: 0, z: 0 },
 | 
			
		||||
@ -388,7 +388,7 @@ const rev = revolve({ axis: 'y' }, part009)
 | 
			
		||||
         z_axis: { x: 0, y: -1, z: 0 }
 | 
			
		||||
       }
 | 
			
		||||
     })`)
 | 
			
		||||
    await expect(u.codeLocator).toContainText(`const sketch003 = startSketchOn({
 | 
			
		||||
    await expect(u.codeLocator).toContainText(`sketch003 = startSketchOn({
 | 
			
		||||
       plane: {
 | 
			
		||||
         origin: { x: 116.53, y: 0, z: 163.25 },
 | 
			
		||||
         x_axis: { x: -0.81, y: 0, z: 0.58 },
 | 
			
		||||
@ -396,7 +396,7 @@ const rev = revolve({ axis: 'y' }, part009)
 | 
			
		||||
         z_axis: { x: 0.58, y: 0, z: 0.81 }
 | 
			
		||||
       }
 | 
			
		||||
     })`)
 | 
			
		||||
    await expect(u.codeLocator).toContainText(`const sketch002 = startSketchOn({
 | 
			
		||||
    await expect(u.codeLocator).toContainText(`sketch002 = startSketchOn({
 | 
			
		||||
       plane: {
 | 
			
		||||
         origin: { x: -91.74, y: 0, z: 80.89 },
 | 
			
		||||
         x_axis: { x: -0.66, y: 0, z: -0.75 },
 | 
			
		||||
@ -415,9 +415,7 @@ const rev = revolve({ axis: 'y' }, part009)
 | 
			
		||||
    await page.keyboard.press('Backspace')
 | 
			
		||||
    await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
 | 
			
		||||
    await page.waitForTimeout(200)
 | 
			
		||||
    await expect(u.codeLocator).not.toContainText(
 | 
			
		||||
      `const sketch005 = startSketchOn({`
 | 
			
		||||
    )
 | 
			
		||||
    await expect(u.codeLocator).not.toContainText(`sketch005 = startSketchOn({`)
 | 
			
		||||
  })
 | 
			
		||||
  test("Deleting solid that the AST mod can't handle results in a toast message", async ({
 | 
			
		||||
    page,
 | 
			
		||||
@ -426,15 +424,15 @@ const rev = revolve({ axis: 'y' }, part009)
 | 
			
		||||
    await page.addInitScript(async () => {
 | 
			
		||||
      localStorage.setItem(
 | 
			
		||||
        'persistCode',
 | 
			
		||||
        `const sketch001 = startSketchOn('XZ')
 | 
			
		||||
        `sketch001 = startSketchOn('XZ')
 | 
			
		||||
  |> startProfileAt([-79.26, 95.04], %)
 | 
			
		||||
  |> line([112.54, 127.64], %, $seg02)
 | 
			
		||||
  |> line([170.36, -121.61], %, $seg01)
 | 
			
		||||
  |> lineTo([profileStartX(%), profileStartY(%)], %)
 | 
			
		||||
  |> close(%)
 | 
			
		||||
const extrude001 = extrude(50, sketch001)
 | 
			
		||||
const launderExtrudeThroughVar = extrude001
 | 
			
		||||
const sketch002 = startSketchOn(launderExtrudeThroughVar, seg02)
 | 
			
		||||
extrude001 = extrude(50, sketch001)
 | 
			
		||||
launderExtrudeThroughVar = extrude001
 | 
			
		||||
sketch002 = startSketchOn(launderExtrudeThroughVar, seg02)
 | 
			
		||||
  |> startProfileAt([-100.54, 16.99], %)
 | 
			
		||||
  |> line([0, 20.03], %)
 | 
			
		||||
  |> line([62.61, 0], %, $seg03)
 | 
			
		||||
@ -490,7 +488,7 @@ const sketch002 = startSketchOn(launderExtrudeThroughVar, seg02)
 | 
			
		||||
    await page.addInitScript(async (KCL_DEFAULT_LENGTH) => {
 | 
			
		||||
      localStorage.setItem(
 | 
			
		||||
        'persistCode',
 | 
			
		||||
        `const part001 = startSketchOn('XZ')
 | 
			
		||||
        `part001 = startSketchOn('XZ')
 | 
			
		||||
    |> startProfileAt([20, 0], %)
 | 
			
		||||
    |> line([7.13, 4 + 0], %)
 | 
			
		||||
    |> angledLine({ angle: 3 + 0, length: 3.14 + 0 }, %)
 | 
			
		||||
@ -714,7 +712,7 @@ const sketch002 = startSketchOn(launderExtrudeThroughVar, seg02)
 | 
			
		||||
    await page.waitForTimeout(200)
 | 
			
		||||
 | 
			
		||||
    await u.removeCurrentCode()
 | 
			
		||||
    await u.codeLocator.fill(`const sketch001 = startSketchOn('XZ')
 | 
			
		||||
    await u.codeLocator.fill(`sketch001 = startSketchOn('XZ')
 | 
			
		||||
  |> startProfileAt([75.8, 317.2], %) // [$startCapTag, $EndCapTag]
 | 
			
		||||
  |> angledLine([0, 268.43], %, $rectangleSegmentA001)
 | 
			
		||||
  |> angledLine([
 | 
			
		||||
@ -727,7 +725,7 @@ const sketch002 = startSketchOn(launderExtrudeThroughVar, seg02)
 | 
			
		||||
     ], %, $yo)
 | 
			
		||||
  |> lineTo([profileStartX(%), profileStartY(%)], %, $seg02)
 | 
			
		||||
  |> close(%)
 | 
			
		||||
const extrude001 = extrude(100, sketch001)
 | 
			
		||||
extrude001 = extrude(100, sketch001)
 | 
			
		||||
  |> chamfer({
 | 
			
		||||
       length: 30,
 | 
			
		||||
       tags: [
 | 
			
		||||
@ -830,7 +828,7 @@ const extrude001 = extrude(100, sketch001)
 | 
			
		||||
    await page.addInitScript(async () => {
 | 
			
		||||
      localStorage.setItem(
 | 
			
		||||
        'persistCode',
 | 
			
		||||
        `const sketch001 = startSketchOn('XZ')
 | 
			
		||||
        `sketch001 = startSketchOn('XZ')
 | 
			
		||||
  |> startProfileAt([3.29, 7.86], %)
 | 
			
		||||
  |> line([2.48, 2.44], %)
 | 
			
		||||
  |> line([2.66, 1.17], %)
 | 
			
		||||
@ -843,7 +841,7 @@ const extrude001 = extrude(100, sketch001)
 | 
			
		||||
  |> line([-3.86, -2.73], %)
 | 
			
		||||
  |> line([-17.67, 0.85], %)
 | 
			
		||||
  |> close(%)
 | 
			
		||||
const extrude001 = extrude(10, sketch001)
 | 
			
		||||
extrude001 = extrude(10, sketch001)
 | 
			
		||||
  `
 | 
			
		||||
      )
 | 
			
		||||
    })
 | 
			
		||||
@ -871,7 +869,7 @@ const extrude001 = extrude(10, sketch001)
 | 
			
		||||
    await expect(page.getByRole('button', { name: 'Extrude' })).toBeDisabled()
 | 
			
		||||
 | 
			
		||||
    const codeToAdd = `${await u.codeLocator.allInnerTexts()}
 | 
			
		||||
const sketch002 = startSketchOn(extrude001, $seg01)
 | 
			
		||||
sketch002 = startSketchOn(extrude001, $seg01)
 | 
			
		||||
  |> startProfileAt([-12.94, 6.6], %)
 | 
			
		||||
  |> line([2.45, -0.2], %)
 | 
			
		||||
  |> line([-2, -1.25], %)
 | 
			
		||||
@ -897,7 +895,7 @@ const sketch002 = startSketchOn(extrude001, $seg01)
 | 
			
		||||
    await page.addInitScript(async () => {
 | 
			
		||||
      localStorage.setItem(
 | 
			
		||||
        'persistCode',
 | 
			
		||||
        `const sketch001 = startSketchOn('XZ')
 | 
			
		||||
        `sketch001 = startSketchOn('XZ')
 | 
			
		||||
  |> startProfileAt([-5, -5], %)
 | 
			
		||||
  |> line([0, 10], %)
 | 
			
		||||
  |> line([10, 0], %)
 | 
			
		||||
@ -925,7 +923,7 @@ const sketch002 = startSketchOn(extrude001, $seg01)
 | 
			
		||||
 | 
			
		||||
    // test fillet button with the body in the scene
 | 
			
		||||
    const codeToAdd = `${await u.codeLocator.allInnerTexts()}
 | 
			
		||||
const extrude001 = extrude(10, sketch001)`
 | 
			
		||||
extrude001 = extrude(10, sketch001)`
 | 
			
		||||
    await u.codeLocator.fill(codeToAdd)
 | 
			
		||||
    await selectSegment()
 | 
			
		||||
    await expect(page.getByRole('button', { name: 'Fillet' })).toBeEnabled()
 | 
			
		||||
@ -964,8 +962,8 @@ const extrude001 = extrude(10, sketch001)`
 | 
			
		||||
      async ({ cases }) => {
 | 
			
		||||
        localStorage.setItem(
 | 
			
		||||
          'persistCode',
 | 
			
		||||
          `const yo = 79
 | 
			
		||||
const part001 = startSketchOn('XZ')
 | 
			
		||||
          `yo = 79
 | 
			
		||||
part001 = startSketchOn('XZ')
 | 
			
		||||
  |> startProfileAt([-7.54, -26.74], %)
 | 
			
		||||
  |> ${cases[0].expectedCode}
 | 
			
		||||
  |> line([-3.19, -138.43], %)
 | 
			
		||||
@ -1016,13 +1014,13 @@ const part001 = startSketchOn('XZ')
 | 
			
		||||
    await page.addInitScript(async () => {
 | 
			
		||||
      localStorage.setItem(
 | 
			
		||||
        'persistCode',
 | 
			
		||||
        `const sketch001 = startSketchOn('XZ')
 | 
			
		||||
        `sketch001 = startSketchOn('XZ')
 | 
			
		||||
  |> startProfileAt([-79.26, 95.04], %)
 | 
			
		||||
  |> line([112.54, 127.64], %)
 | 
			
		||||
  |> line([170.36, -121.61], %, $seg01)
 | 
			
		||||
  |> lineTo([profileStartX(%), profileStartY(%)], %)
 | 
			
		||||
  |> close(%)
 | 
			
		||||
const extrude001 = extrude(50, sketch001)
 | 
			
		||||
extrude001 = extrude(50, sketch001)
 | 
			
		||||
        `
 | 
			
		||||
      )
 | 
			
		||||
    })
 | 
			
		||||
@ -1129,7 +1127,7 @@ const extrude001 = extrude(50, sketch001)
 | 
			
		||||
      }: any) => {
 | 
			
		||||
        localStorage.setItem(
 | 
			
		||||
          'persistCode',
 | 
			
		||||
          `const part001 = startSketchOn('XZ')
 | 
			
		||||
          `part001 = startSketchOn('XZ')
 | 
			
		||||
    ${extrudeAndEditBlocked}
 | 
			
		||||
    |> line([25.96, 2.93], %)
 | 
			
		||||
    |> line([5.25, -5.72], %)
 | 
			
		||||
@ -1137,14 +1135,14 @@ const extrude001 = extrude(50, sketch001)
 | 
			
		||||
    |> line([-27.65, -2.78], %)
 | 
			
		||||
    |> close(%)
 | 
			
		||||
    |> extrude(5, %)
 | 
			
		||||
  const sketch002 = startSketchOn('XZ')
 | 
			
		||||
  sketch002 = startSketchOn('XZ')
 | 
			
		||||
    ${extrudeAndEditAllowed}
 | 
			
		||||
    |> line([10.32, 6.47], %)
 | 
			
		||||
    |> line([9.71, -6.16], %)
 | 
			
		||||
    |> line([-3.08, -9.86], %)
 | 
			
		||||
    |> line([-12.02, -1.54], %)
 | 
			
		||||
    |> close(%)
 | 
			
		||||
  const sketch003 = startSketchOn('XZ')
 | 
			
		||||
  sketch003 = startSketchOn('XZ')
 | 
			
		||||
    ${editOnly}
 | 
			
		||||
    |> line([27.55, -1.65], %)
 | 
			
		||||
    |> line([4.95, -8], %)
 | 
			
		||||
@ -1152,7 +1150,7 @@ const extrude001 = extrude(50, sketch001)
 | 
			
		||||
    |> line([-15.79, 17.08], %)
 | 
			
		||||
 | 
			
		||||
  fn yohey = (pos) => {
 | 
			
		||||
    const sketch004 = startSketchOn('XZ')
 | 
			
		||||
    sketch004 = startSketchOn('XZ')
 | 
			
		||||
    ${extrudeAndEditBlockedInFunction}
 | 
			
		||||
    |> line([27.55, -1.65], %)
 | 
			
		||||
    |> line([4.95, -10.53], %)
 | 
			
		||||
@ -1233,7 +1231,7 @@ const extrude001 = extrude(50, sketch001)
 | 
			
		||||
    await page.mouse.click(700, 200)
 | 
			
		||||
 | 
			
		||||
    await expect(page.locator('.cm-content')).toHaveText(
 | 
			
		||||
      `const sketch001 = startSketchOn('XZ')`
 | 
			
		||||
      `sketch001 = startSketchOn('XZ')`
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    await page.waitForTimeout(600)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user