[Ur] Mysterious behavior: Simple example DOES NOT compile using table named `thing` - but identical code DOES compile and run fine after renaming table `thing` to table `t`

Stefan Scott Alexander stefanscottalexx at gmail.com
Fri Jul 24 00:52:08 EDT 2015


Hello -

In order to do some testing and studying, I am playing with an extremely
simplified example, using the Ur/Web Sql demo as a starting point:

http://www.impredicative.com/ur/demo/sql.html

That demo had one table called `t`:

table t : { A : int, B : float, C : string, D : bool }
  PRIMARY KEY A

My example extends this very slightly, to use a "parent" table `color` and
"child" table `thing`:

table color : {
  Id : int,
  Nam : string
}
  PRIMARY KEY Id

table thing : {
  Id : int,
  Nam : string,
  Color : int
}
  PRIMARY KEY Id,
  CONSTRAINT Color FOREIGN KEY Color REFERENCES color(Id)

To keep things ultra-simple, there is no GUI for "parent" table `color` -
it has to be populated using psql.

===

The new code, which is very short, is in this github repo:

https://github.com/StefanScott/urweb-color-thing-THING

The above code DOES NOT compile, giving some unification failure error
messages about tables `thing` and `t`. These compiler errors are shown in
Issue 1 on the above github repo:

https://github.com/StefanScott/urweb-color-thing-THING/issues/1

===

Mystery:

There is no table `t` mentioned anywhere in the above github repo!

(There WAS a table `t` in the original Sql demo, but I had already renamed
all occurrences of it to table `thing`.)

Extra checking:

I have done a search (for string "t" - whole words, non-case-sensitive) to
confirm that there are no occurrences of a table `t` anywhere in the above
github repo. Nevertheless, the compiler keeps referring to a mysterious
table `t`, which does not match the table `thing`, so the code doesn't
compile.

I have also carefully checked the upper- and lower-case for all the table
names, field names, and structure names, and they look fine. I have also
checked additional things: (a) confirming that ReadError is only used on
numeric fields; (b) confirming that neither table uses a sequence for the
`Id` field.

===

Now, as a test, I renamed all occurrences of table `thing` to `t` in the
above github repo, producing a new, separate github repo:

https://github.com/StefanScott/urweb-color-thing-T

The code in this repo (identical to the code in the previous repo, except
all occurrences of table `thing` have been renamed to table `t`) DOES
compile and run fine!

===

So the above two github repos are identical - except one uses a table
called `thing` and the other uses a table called `t`.

The code using table `thing` DOES NOT compile (and complains about
unification errors involving a non-existent table `t`) - but the code using
table `t` DOES compile and runs fine!

Why is this?

===

Note: I have also tried extending this, adding a struct for table `color`.
When attempting to compile using two different structs for tables `color`
and `thing`, there are twice as many compiler errors - always complaining
about the same unification failures with some mysterious, non-existent
table `t`.

Thanks for any help solving this mystery!

###
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150724/bfd972d3/attachment.html>


More information about the Ur mailing list