Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing local #1625

Open
Johnicholas opened this issue Aug 27, 2023 · 4 comments
Open

Missing local #1625

Johnicholas opened this issue Aug 27, 2023 · 4 comments

Comments

@Johnicholas
Copy link

.domain:

type Box
type Place <: Box
type Transition <: Box
type Arrow

constructor Arrow(Box b1, Box b2)

.substance:

Place work_in
Place dev_in
Transition start
Place px
Place py
Transition delegate
Transition stop
Place work_out
Place dev_out

Arrow work_in_start := Arrow(work_in, start)
Arrow dev_in_delegate := Arrow(dev_in, delegate)
Arrow start_v1_i := Arrow(start, px) for i in [0, 4]

Arrow px_delegate := Arrow(px, delegate)
Arrow py_stop_i := Arrow(py, stop) for i in [0, 4]
Arrow stop_start_i := Arrow(stop, start) for i in [0, 4]
Arrow stop_work_out := Arrow(stop, work_out)
Arrow delegate_dev_out := Arrow(delegate, dev_out)

AutoLabel All

.style:

canvas {
    width = 1000
    height = 1000
}

GLOBAL {
    REST_LENGTH = 500

    COLOR_BLACK = #000000ff
    COLOR_WHITE = #ffffffff
    COLOR_DEBUG = #ff0000ff
}

layout = [boxes, arrows]

forall Box b {
    b.center = (? in boxes, ? in boxes, ? in boxes, ? in boxes, ? in boxes)
    vec2 b.projected_center = (b.center[0], b.center[1])
}

forall Place p {
    shape p.icon = Circle {
        center: p.projected_center
        r: 30
        strokeWidth: 1
        strokeColor: GLOBAL.COLOR_BLACK
        fillColor: GLOBAL.COLOR_WHITE
    }
    shape p.arrowTarget = p.icon
}

forall Transition t {
    shape t.icon = Rectangle {
        center: t.projected_center
        width: 15
        height: 15
        fillColor: GLOBAL.COLOR_BLACK
    }
    shape t.arrowTarget = Rectangle {
        center: t.projected_center
        width: 15
        height: 15
        fillColor: GLOBAL.COLOR_DEBUG
    }
    t.arrowTarget above t.icon
}

forall Box b1; Box b2 {
    encourage maximal(vdist(b1.center, b2.center)) in boxes
    ensure disjoint(b1.icon, b2.icon)
}

forall Arrow a; Box b1; Box b2 where a := Arrow(b1, b2) {
    -- hooke's law attraction of boxes connected by arrows?
    encourage equal(0, sqr(vdist(b1.center, b2.center) - GLOBAL.REST_LENGTH)) in boxes

    vec2 a.start = (? in arrows, ? in arrows)
    encourage equal(0, norm(closestPoint(b1.arrowTarget, b2.projected_center) - a.start)) in arrows
    vec2 a.end = closestPoint(b2.arrowTarget, b1.projected_center)
    shape a.line = Line {
        start: a.start
        end: a.end
        endArrowhead: "straight"
        strokeColor: GLOBAL.COLOR_BLACK
    }

    a.firstCorner = (? in arrows, ? in arrows)
    a.secondCorner = (? in arrows, ? in arrows)
    -- ensure equal(a.start[1], a.firstCorner[1]) in arrows
    -- ensure equal(a.firstCorner[0], a.secondCorner[0]) in arrows
    -- ensure equal(a.secondCorner[1], a.end[1]) in arrows

    shape a.debugFirstCornerDebug = Circle {
        center: a.firstCorner
        r: 6
        fillColor: GLOBAL.COLOR_DEBUG
    }

    shape a.debugSecondCornerDebug = Circle {
        center: a.secondCorner
        r: 6
        fillColor: GLOBAL.COLOR_DEBUG
    }

    shape a.debugLineOne = Line {
        start: a.start
        end: a.firstCorner
        strokeColor: GLOBAL.COLOR_DEBUG
    }

    shape a.debugLineTwo = Line {
        start: a.firstCorner
        end: a.secondCorner
        strokeColor: GLOBAL.COLOR_DEBUG
    }

    shape a.debugLineThree = Line {
        start: a.secondCorner
        end: a.end
        strokeColor: GLOBAL.COLOR_DEBUG
    }

    encourage minimal(perimeter([a.start, a.firstCorner, a.secondCorner, a.end], false)) in arrows
    -- encourage equal(0, norm(a.firstCorner - a.start) + norm(a.secondCorner - a.firstCorner) + norm(a.end - a.secondCorner)) in arrows
    ensure isEquilateral([a.start, a.firstCorner, a.secondCorner, a.end], false) in arrows
}

-- collect Box b into boxes {
--     centers = listof center from boxes
--     projected_centers = listof projected_center from boxes
--     encourage minimal(tsneEnergy(centers, projected_centers))
-- }

Error message:

Uncaught (in promise) TypeError: missing local
    at ru (index-0629f25b.js:236:22024)
    at AT (index-0629f25b.js:247:19681)
    at KAe (index-0629f25b.js:247:20722)
    at index-0629f25b.js:247:21692
    at Array.map (<anonymous>)
    at KU (index-0629f25b.js:247:21662)
    at ngt (index-0629f25b.js:247:24285)
    at hAt (index-0629f25b.js:266:2926)
    at async dAt (index-0629f25b.js:266:3451)
    at async CFe (index-0629f25b.js:308:7815)
index-0629f25b.js:236 Uncaught (in promise) TypeError: missing local
    at ru (index-0629f25b.js:236:22024)
    at AT (index-0629f25b.js:247:19681)
    at KAe (index-0629f25b.js:247:20722)
    at index-0629f25b.js:247:21692
    at Array.map (<anonymous>)
    at KU (index-0629f25b.js:247:21662)
    at ngt (index-0629f25b.js:247:24285)
    at hAt (index-0629f25b.js:266:2926)
    at async dAt (index-0629f25b.js:266:3451)
    at async CFe (index-0629f25b.js:308:7815)
ru @ index-0629f25b.js:236
AT @ index-0629f25b.js:247
KAe @ index-0629f25b.js:247
(anonymous) @ index-0629f25b.js:247
KU @ index-0629f25b.js:247
ngt @ index-0629f25b.js:247
hAt @ index-0629f25b.js:266
index-0629f25b.js:236 Uncaught (in promise) TypeError: missing local
    at ru (index-0629f25b.js:236:22024)
    at AT (index-0629f25b.js:247:19681)
    at KAe (index-0629f25b.js:247:20722)
    at index-0629f25b.js:247:21692
    at Array.map (<anonymous>)
    at KU (index-0629f25b.js:247:21662)
    at ngt (index-0629f25b.js:247:24285)
    at hAt (index-0629f25b.js:266:2926)
    at async dAt (index-0629f25b.js:266:3451)
    at async CFe (index-0629f25b.js:308:7815)
contextKeyService.ts:394 Element already has context attribute
@wodeni
Copy link
Member

wodeni commented Aug 28, 2023

Can't reproduce yet but created a sharable link for this trio: https://penrose.cs.cmu.edu/try/?gist=47f337506eb5f0500ed1cf1c98a8061c. Thanks for reporting @Johnicholas!!

@samestep
Copy link
Collaborator

Interesting; that error message comes from here:

const getIndex = (locals: Locals, id: ad.Id): number => {
const local = safe(locals.indices.get(id), "missing local");
return (
numAddendParams +
(local.typename === "i32" ? 0 : locals.counts.i32) +
local.index
);
};

Seems like a bug? But @wodeni you said you're unable to reproduce?

@Johnicholas
Copy link
Author

Another occurrence of the same error message:

index-b4db132c.js:236 Uncaught (in promise) TypeError: missing local
    at ru (index-b4db132c.js:236:22024)
    at AT (index-b4db132c.js:247:19681)
    at KAe (index-b4db132c.js:247:20722)
    at index-b4db132c.js:247:21692
    at Array.map (<anonymous>)
    at JU (index-b4db132c.js:247:21662)
    at rgt (index-b4db132c.js:247:24285)
    at fAt (index-b4db132c.js:266:2926)
    at async mAt (index-b4db132c.js:266:3451)
    at async wFe (index-b4db132c.js:308:7815)

image

.domain empty, .substance empty, .style:

canvas {
    width = 1000
    height = 1000
}

GLOBAL {
    COLOR_TRANSPARENT = #00000000
    COLOR_DEBUG = #ff0000ff
    COLOR_BLACK = #000000ff


    -- sqrtFirstRun = 10 -- or ?
    -- firstRun = sqr(sqrtFirstRun)
    -- a = (?, ?)
    -- b = a + (firstRun, 0)
    -- sqrtSecondRun = 10 -- or ?
    -- secondRun = sqr(sqrtSecondRun)
    -- sqrtRise = 10 -- or ?
    -- rise = sqr(sqrtRise)
    -- c = b + (secondRun, rise)
    -- sqrtThirdRun = 10 -- or ?
    -- thirdRun = sqr(sqrtThirdRun)
    -- d = c + (thirdRun, 0)
    -- ab = Line {
    --     start: a
    --     end: b
    -- }
    -- bc = Line {
    --     start: b
    --     end: c
    -- }
    -- cd = Line {
    --     start: c
    --     end: d
    -- }
    -- -- Polyline {
    -- --     points: [a, b, c, d]
    -- -- }
    -- -- ensure a[1] == b[1]
    -- -- ensure a[0] < b[0]
    -- -- ensure b[0] < c[0]
    -- -- ensure c[0] < d[0]
    -- -- ensure c[1] == d[1]
    -- -- ensure a[1] < c[1]
    -- -- firstCornerCenter = (?, ?)
    -- firstCornerCircle = Circle {
    --     fillColor: COLOR_TRANSPARENT
    --     r: 50
    --     strokeWidth: 1
    --     strokeColor: COLOR_BLACK
    -- }

    -- Circle {
    --     center: firstCornerCircle.center
    --     r: 6
    --     fillColor: COLOR_DEBUG
    -- }
    -- Circle {
    --     center: closestPointLine(a, b, firstCornerCircle.center)
    --     r: 6
    --     fillColor: COLOR_DEBUG
    -- }
    -- Circle {
    --     center: closestPointLine(b, c, firstCornerCircle.center)
    --     r: 6
    --     fillColor: COLOR_DEBUG
    -- }
    -- ensure 

    -- ensure signedDistanceLine(a, b, firstCornerCircle.center) == firstCornerCircle.r
    -- ensure signedDistanceLine(b, c, firstCornerCircle.center) == firstCornerCircle.r
    -- ensure signedArea([closestPointLine(a, b, firstCornerCircle.center), firstCornerCircle.center, closestPointLine(b, c, firstCornerCircle.center)], true) > 10


    -- secondCornerCircle = Circle {
    --     fillColor: COLOR_TRANSPARENT
    --     r: 50
    --     strokeWidth: 1
    --     strokeColor: COLOR_BLACK
    -- }
    -- ensure signedDistanceLine(b, c, secondCornerCircle.center) == secondCornerCircle.r
    -- ensure signedDistanceLine(c, d, secondCornerCircle.center) == secondCornerCircle.r
    -- ensure secondCornerCircle.center[1] < c[1]
    -- Circle {
    --     center: closestPointLine(b, c, secondCornerCircle.center)
    --     r: 6
    --     fillColor: COLOR_DEBUG
    -- }
    -- Circle {
    --     center: closestPointLine(c, d, secondCornerCircle.center)
    --     r: 6
    --     fillColor: COLOR_DEBUG
    -- }

    -- a = (?, ?)
    -- b = (?, ?)
    -- c = (?, ?)
    -- d = (?, ?)
    -- line1 = Line {
    --     start: a
    --     end: b
    -- }
    -- circle1 = Circle {
    --     fillColor: COLOR_TRANSPARENT
    --     strokeWidth: 1
    --     strokeColor: COLOR_BLACK
    -- }
    -- ensure collinearOrdered(a, closestPointLine(a, b, circle1.center), b)
    -- ensure vdist(closestPointLine(a, b, circle1.center), circle1.center) == circle1.r
    -- line2 = Line {
    --     start: b
    --     end: c
    -- }
    -- ensure collinearOrdered(b, closestPointLine(b, c, circle1.center), c)
    -- ensure vdist(closestPointLine(b, c, circle1.center), circle1.center) == circle1.r

    a = (?, ?)
    b = (?, ?)
    c = (?, ?)
    d = (?, ?)
    Line {
        start: a
        end: b
    }
    Line {
        start: b
        end: c
    }
    Line {
        start: c
        end: d
    }
    Circle {
        center: innerPointOffset(a, b, c, 50)
        r: 6
        fillColor: COLOR_DEBUG
    }
}

I am guessing it has something to do with using the /try editor for a while.

@Johnicholas
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants