bootstrapworld / pyret-blocks

Block Language for the Pyret Programming Language
Apache License 2.0
3 stars 1 forks source link

Clicking on Name of Custom Datatype Workaround #19

Open maroon-scorch opened 3 years ago

maroon-scorch commented 3 years ago

Whenever a custom datatype such as the following is rendered in the program:

data Posn:
  | posn(x :: Number, y :: Number)
  | nice(s :: String)
end 

The block node of the title of the datatype "Posn" is rendered as "blocks-node-undefined" with an undefined id, and consequently clicking on the name also crashes the program. The workaround currently is to instead render the title using the String of the title instead. The tradeoff is that custom datatype names are currently uneditable.

The relevant constructor is the class Data in "ast.tsx" and the class s-data in "PyretParser.ts"

RobScheidegger commented 3 years ago

Fixed by re-implementing the Nodes.Literal rendering and changing Spec.value('name') to Spec.required('name') in the body of the Data AST Node.

However, the problem was that because the spec for the property was value, the block was being rendered with no id since it wasn't being assigned in AST.annotateNodes() in CodemirrorBlocks (since I assume that value tells it that it is not an AST node), which leads me to suggest maybe a check somewhere to catch undefined id prior to render and throw a more precise error. Otherwise, this appears relatively mystic and strange to debug.